From d9512c5995a18f8d9fd0c74100d5f423f3b3e277 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Tue, 27 Aug 2024 19:44:27 -0700 Subject: [PATCH] Update SQL engine snapshots --- .../test_semi_additive_join_node__plan0.sql | 39 +++++++++++++++++++ ...mi_additive_join_node__plan0_optimized.sql | 26 +++++++++++++ ...dditive_join_node_with_grouping__plan0.sql | 39 +++++++++++++++++++ ...in_node_with_grouping__plan0_optimized.sql | 26 +++++++++++++ ...join_node_with_queried_group_by__plan0.sql | 39 +++++++++++++++++++ ...with_queried_group_by__plan0_optimized.sql | 26 +++++++++++++ .../test_semi_additive_join_node__plan0.sql | 39 +++++++++++++++++++ ...mi_additive_join_node__plan0_optimized.sql | 26 +++++++++++++ ...dditive_join_node_with_grouping__plan0.sql | 39 +++++++++++++++++++ ...in_node_with_grouping__plan0_optimized.sql | 26 +++++++++++++ ...join_node_with_queried_group_by__plan0.sql | 39 +++++++++++++++++++ ...with_queried_group_by__plan0_optimized.sql | 26 +++++++++++++ .../test_semi_additive_join_node__plan0.sql | 39 +++++++++++++++++++ ...mi_additive_join_node__plan0_optimized.sql | 26 +++++++++++++ ...dditive_join_node_with_grouping__plan0.sql | 39 +++++++++++++++++++ ...in_node_with_grouping__plan0_optimized.sql | 26 +++++++++++++ ...join_node_with_queried_group_by__plan0.sql | 39 +++++++++++++++++++ ...with_queried_group_by__plan0_optimized.sql | 26 +++++++++++++ .../test_semi_additive_join_node__plan0.sql | 39 +++++++++++++++++++ ...mi_additive_join_node__plan0_optimized.sql | 26 +++++++++++++ ...dditive_join_node_with_grouping__plan0.sql | 39 +++++++++++++++++++ ...in_node_with_grouping__plan0_optimized.sql | 26 +++++++++++++ ...join_node_with_queried_group_by__plan0.sql | 39 +++++++++++++++++++ ...with_queried_group_by__plan0_optimized.sql | 26 +++++++++++++ .../test_semi_additive_join_node__plan0.sql | 39 +++++++++++++++++++ ...mi_additive_join_node__plan0_optimized.sql | 26 +++++++++++++ ...dditive_join_node_with_grouping__plan0.sql | 39 +++++++++++++++++++ ...in_node_with_grouping__plan0_optimized.sql | 26 +++++++++++++ ...join_node_with_queried_group_by__plan0.sql | 39 +++++++++++++++++++ ...with_queried_group_by__plan0_optimized.sql | 26 +++++++++++++ .../test_semi_additive_join_node__plan0.sql | 39 +++++++++++++++++++ ...mi_additive_join_node__plan0_optimized.sql | 26 +++++++++++++ ...dditive_join_node_with_grouping__plan0.sql | 39 +++++++++++++++++++ ...in_node_with_grouping__plan0_optimized.sql | 26 +++++++++++++ ...join_node_with_queried_group_by__plan0.sql | 39 +++++++++++++++++++ ...with_queried_group_by__plan0_optimized.sql | 26 +++++++++++++ 36 files changed, 1170 insertions(+) diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0.sql index 603cac9c69..1eec0035f0 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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(DATE_TRUNC('month', ds), month) AS ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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(DATE_TRUNC('month', ds), month) AS account__ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -73,6 +99,7 @@ INNER JOIN ( 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 @@ -84,6 +111,12 @@ INNER JOIN ( , 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(DATE_TRUNC('month', ds), month) AS ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -96,6 +129,12 @@ INNER JOIN ( , 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(DATE_TRUNC('month', ds), month) AS account__ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0_optimized.sql index 090ed3d620..fabd6a2a40 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATETIME_TRUNC(ds, day) AS ds__day , DATETIME_TRUNC(ds, isoweek) AS ds__week , DATETIME_TRUNC(ds, month) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , IF(EXTRACT(dayofweek FROM ds) = 1, 7, EXTRACT(dayofweek FROM ds) - 1) AS ds__extract_dow , EXTRACT(dayofyear FROM ds) AS ds__extract_doy + , DATETIME_TRUNC(DATE_TRUNC('month', ds), month) AS ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATETIME_TRUNC(ds, day) AS account__ds__day , DATETIME_TRUNC(ds, isoweek) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , IF(EXTRACT(dayofweek FROM ds) = 1, 7, EXTRACT(dayofweek FROM ds) - 1) AS account__ds__extract_dow , EXTRACT(dayofyear FROM ds) AS account__ds__extract_doy + , DATETIME_TRUNC(DATE_TRUNC('month', ds), month) AS account__ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0.sql index 204e39e8d3..cb91d894ad 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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(DATE_TRUNC('month', ds), month) AS ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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(DATE_TRUNC('month', ds), month) AS account__ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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(DATE_TRUNC('month', ds), month) AS ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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(DATE_TRUNC('month', ds), month) AS account__ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index 7bc2a27483..8205cd89ed 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATETIME_TRUNC(ds, day) AS ds__day , DATETIME_TRUNC(ds, isoweek) AS ds__week , DATETIME_TRUNC(ds, month) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , IF(EXTRACT(dayofweek FROM ds) = 1, 7, EXTRACT(dayofweek FROM ds) - 1) AS ds__extract_dow , EXTRACT(dayofyear FROM ds) AS ds__extract_doy + , DATETIME_TRUNC(DATE_TRUNC('month', ds), month) AS ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATETIME_TRUNC(ds, day) AS account__ds__day , DATETIME_TRUNC(ds, isoweek) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , IF(EXTRACT(dayofweek FROM ds) = 1, 7, EXTRACT(dayofweek FROM ds) - 1) AS account__ds__extract_dow , EXTRACT(dayofyear FROM ds) AS account__ds__extract_doy + , DATETIME_TRUNC(DATE_TRUNC('month', ds), month) AS account__ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0.sql index 15a982bc1b..47bd7f6fa0 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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(DATE_TRUNC('month', ds), month) AS ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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(DATE_TRUNC('month', ds), month) AS account__ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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(DATE_TRUNC('month', ds), month) AS ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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(DATE_TRUNC('month', ds), month) AS account__ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index adb1d564c8..bb27aceeba 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATETIME_TRUNC(ds, day) AS ds__day , DATETIME_TRUNC(ds, isoweek) AS ds__week , DATETIME_TRUNC(ds, month) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , IF(EXTRACT(dayofweek FROM ds) = 1, 7, EXTRACT(dayofweek FROM ds) - 1) AS ds__extract_dow , EXTRACT(dayofyear FROM ds) AS ds__extract_doy + , DATETIME_TRUNC(DATE_TRUNC('month', ds), month) AS ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATETIME_TRUNC(ds, day) AS account__ds__day , DATETIME_TRUNC(ds, isoweek) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , IF(EXTRACT(dayofweek FROM ds) = 1, 7, EXTRACT(dayofweek FROM ds) - 1) AS account__ds__extract_dow , EXTRACT(dayofyear FROM ds) AS account__ds__extract_doy + , DATETIME_TRUNC(DATE_TRUNC('month', ds), month) AS account__ds_month__month + , DATETIME_TRUNC(DATE_TRUNC('month', ds), quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(DATE_TRUNC('month', ds), year) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0.sql index 44b9beb062..3164cdc40b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -73,6 +99,7 @@ INNER JOIN ( 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 @@ -84,6 +111,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -96,6 +129,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0_optimized.sql index 898e433670..22fabb31fb 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(DAYOFWEEK_ISO FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(DAYOFWEEK_ISO FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0.sql index 2b69c18f94..da0d119ddc 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index c29e6b7c0e..e9df08c582 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(DAYOFWEEK_ISO FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(DAYOFWEEK_ISO FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0.sql index 483cb8a7b8..907fcc80c3 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index 593e991f90..7b30d93a21 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(DAYOFWEEK_ISO FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(DAYOFWEEK_ISO FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0.sql index 7e857e24d3..48cbe70b30 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -73,6 +99,7 @@ INNER JOIN ( 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 @@ -84,6 +111,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -96,6 +129,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0_optimized.sql index d159a6215c..342fd6dbf5 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(isodow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(isodow FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0.sql index f6d73bba58..dd1ea08581 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index 23e7270ba7..776f847b9b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(isodow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(isodow FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0.sql index d15252a07e..0a73c96e05 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index 2059c7c53a..299780514c 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(isodow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(isodow FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0.sql index e0da6b368c..5b1848a025 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -73,6 +99,7 @@ INNER JOIN ( 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 @@ -84,6 +111,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -96,6 +129,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0_optimized.sql index 8790159c85..714ee82487 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , CASE WHEN EXTRACT(dow FROM ds) = 0 THEN EXTRACT(dow FROM ds) + 7 ELSE EXTRACT(dow FROM ds) END AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , CASE WHEN EXTRACT(dow FROM ds) = 0 THEN EXTRACT(dow FROM ds) + 7 ELSE EXTRACT(dow FROM ds) END AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0.sql index 9a90e73c6d..9c563cc00f 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index 406c588c63..5675b345cc 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , CASE WHEN EXTRACT(dow FROM ds) = 0 THEN EXTRACT(dow FROM ds) + 7 ELSE EXTRACT(dow FROM ds) END AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , CASE WHEN EXTRACT(dow FROM ds) = 0 THEN EXTRACT(dow FROM ds) + 7 ELSE EXTRACT(dow FROM ds) END AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0.sql index fbc5127dc6..bca01829b4 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index f81ddba6c9..5df6e0ff65 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , CASE WHEN EXTRACT(dow FROM ds) = 0 THEN EXTRACT(dow FROM ds) + 7 ELSE EXTRACT(dow FROM ds) END AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , CASE WHEN EXTRACT(dow FROM ds) = 0 THEN EXTRACT(dow FROM ds) + 7 ELSE EXTRACT(dow FROM ds) END AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0.sql index 07052ef0f2..802ea7f715 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -73,6 +99,7 @@ INNER JOIN ( 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 @@ -84,6 +111,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -96,6 +129,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0_optimized.sql index e2dc17ba69..4e5fca702e 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dayofweekiso FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(dayofweekiso FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0.sql index f465bab0f9..7225ebbc4a 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index 9e9d03bd02..86682eef21 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dayofweekiso FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(dayofweekiso FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0.sql index bc47f78312..5cd320f91a 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index 14d2446f48..1f67dbf38e 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dayofweekiso FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(dayofweekiso FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node__plan0.sql index f9ca1bb92e..7ef911c9e4 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -73,6 +99,7 @@ INNER JOIN ( 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 @@ -84,6 +111,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -96,6 +129,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node__plan0_optimized.sql index fcf6da5d40..817c8d7a43 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(DAY_OF_WEEK FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(DAY_OF_WEEK FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_grouping__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_grouping__plan0.sql index 891a5e7634..5653b21501 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_grouping__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index c5d4f50c46..76bfbb1941 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(DAY_OF_WEEK FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(DAY_OF_WEEK FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_queried_group_by__plan0.sql index 153ba096c5..46a08175d8 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_0.ds_month__quarter AS ds_month__quarter + , subq_0.ds_month__year AS ds_month__year + , subq_0.ds_month__extract_year AS ds_month__extract_year + , subq_0.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_0.ds_month__extract_month AS ds_month__extract_month , subq_0.account__ds__day AS account__ds__day , subq_0.account__ds__week AS account__ds__week , subq_0.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_0.account__ds__extract_day AS account__ds__extract_day , subq_0.account__ds__extract_dow AS account__ds__extract_dow , subq_0.account__ds__extract_doy AS account__ds__extract_doy + , subq_0.account__ds_month__month AS account__ds_month__month + , subq_0.account__ds_month__quarter AS account__ds_month__quarter + , subq_0.account__ds_month__year AS account__ds_month__year + , subq_0.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month AS account__ds_month__extract_month , subq_0.user AS user , subq_0.account__user AS account__user , subq_0.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_0.account_balance AS account_balance , subq_0.total_account_balance_first_day AS total_account_balance_first_day , subq_0.current_account_balance_by_user AS current_account_balance_by_user + , subq_0.total_account_balance_first_day_of_month AS 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 @@ -46,6 +60,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -58,6 +78,12 @@ FROM ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -74,6 +100,7 @@ INNER JOIN ( 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 @@ -85,6 +112,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 @@ -97,6 +130,12 @@ INNER JOIN ( , 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', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) 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 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index fe4e69f567..8867c5f8ef 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -11,6 +11,12 @@ SELECT , 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_month__month AS ds_month__month + , subq_3.ds_month__quarter AS ds_month__quarter + , subq_3.ds_month__year AS ds_month__year + , subq_3.ds_month__extract_year AS ds_month__extract_year + , subq_3.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_3.ds_month__extract_month AS ds_month__extract_month , subq_3.account__ds__day AS account__ds__day , subq_3.account__ds__week AS account__ds__week , subq_3.account__ds__month AS account__ds__month @@ -22,6 +28,12 @@ SELECT , subq_3.account__ds__extract_day AS account__ds__extract_day , subq_3.account__ds__extract_dow AS account__ds__extract_dow , subq_3.account__ds__extract_doy AS account__ds__extract_doy + , subq_3.account__ds_month__month AS account__ds_month__month + , subq_3.account__ds_month__quarter AS account__ds_month__quarter + , subq_3.account__ds_month__year AS account__ds_month__year + , subq_3.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_3.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_3.account__ds_month__extract_month AS account__ds_month__extract_month , subq_3.user AS user , subq_3.account__user AS account__user , subq_3.account_type AS account_type @@ -29,12 +41,14 @@ SELECT , subq_3.account_balance AS account_balance , subq_3.total_account_balance_first_day AS total_account_balance_first_day , subq_3.current_account_balance_by_user AS current_account_balance_by_user + , subq_3.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' SELECT account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user + , account_balance AS total_account_balance_first_day_of_month , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month @@ -46,6 +60,12 @@ FROM ( , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(DAY_OF_WEEK FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS ds_month__extract_month , account_type , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week @@ -58,6 +78,12 @@ FROM ( , EXTRACT(day FROM ds) AS account__ds__extract_day , EXTRACT(DAY_OF_WEEK FROM ds) AS account__ds__extract_dow , EXTRACT(doy FROM ds) AS account__ds__extract_doy + , DATE_TRUNC('month', DATE_TRUNC('month', ds)) AS account__ds_month__month + , DATE_TRUNC('quarter', DATE_TRUNC('month', ds)) AS account__ds_month__quarter + , DATE_TRUNC('year', DATE_TRUNC('month', ds)) AS account__ds_month__year + , EXTRACT(year FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_year + , EXTRACT(quarter FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_quarter + , EXTRACT(month FROM DATE_TRUNC('month', ds)) AS account__ds_month__extract_month , account_type AS account__account_type , user_id AS user , user_id AS account__user