diff --git a/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/user_sm_source.yaml b/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/user_sm_source.yaml index dacb9689cf..9bc85fcfdc 100644 --- a/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/user_sm_source.yaml +++ b/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/user_sm_source.yaml @@ -54,3 +54,55 @@ semantic_model: expr: "1" agg: SUM create_metric: true + - name: archived_users + expr: "1" + agg: SUM + create_metric: true + agg_time_dimension: archived_at +--- +metric: + name: subdaily_cumulative_window_metric + description: cumulative window metric with a sub-daily agg time dim + type: cumulative + type_params: + measure: archived_users + cumulative_type_params: + window: 3 hours +--- +metric: + name: subdaily_cumulative_grain_to_date_metric + description: cumulative grain to date metric with a sub-daily agg time dim + type: cumulative + type_params: + measure: archived_users + cumulative_type_params: + grain_to_date: hour +--- +metric: + name: subdaily_offset_window_metric + description: offset window metric with a sub-daily agg time dim + type: derived + type_params: + expr: archived_users + metrics: + - name: archived_users + offset_window: 1 hour +--- +metric: + name: subdaily_offset_grain_to_date_metric + description: offset grain to date metric with a sub-daily agg time dim + type: derived + type_params: + expr: archived_users + metrics: + - name: archived_users + offset_to_grain: hour +--- +metric: + name: subdaily_join_to_time_spine_metric + description: simple metric with sub-daily agg time dim that joins to time spine + type: simple + type_params: + measure: + name: archived_users + join_to_timespine: true diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_linkable_spec_resolver.py/list/test_linkable_element_set_as_spec_set__set0.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_linkable_spec_resolver.py/list/test_linkable_element_set_as_spec_set__set0.txt index 81f7d1538e..3c2e4a6bfe 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_linkable_spec_resolver.py/list/test_linkable_element_set_as_spec_set__set0.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_linkable_spec_resolver.py/list/test_linkable_element_set_as_spec_set__set0.txt @@ -186,6 +186,7 @@ 'user__archived_at__quarter', 'user__archived_at__week', 'user__archived_at__year', + 'user__archived_users', 'user__bio_added_ts__day', 'user__bio_added_ts__extract_day', 'user__bio_added_ts__extract_day', @@ -456,6 +457,7 @@ 'user__revenue_instance__user__revenue', 'user__revenue_instance__user__revenue_all_time', 'user__smallest_listing', + 'user__subdaily_join_to_time_spine_metric', 'user__total_account_balance_first_day', 'user__verification__user__identity_verifications', 'user__view__user__views', diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/dict/test_get_names__result0.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/dict/test_get_names__result0.txt index f52d494f84..6204c4d106 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/dict/test_get_names__result0.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/dict/test_get_names__result0.txt @@ -24,6 +24,7 @@ 'account_balance', 'approximate_continuous_booking_value_p99', 'approximate_discrete_booking_value_p99', + 'archived_users', 'average_booking_value', 'bookers', 'booking_payments', diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/str/test_linkable_elements_for_measure__result0.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/str/test_linkable_elements_for_measure__result0.txt index fa3dcb7aae..49910102bd 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/str/test_linkable_elements_for_measure__result0.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/str/test_linkable_elements_for_measure__result0.txt @@ -177,6 +177,7 @@ Model Join-Path Entity Links ('listings_latest',) ("('user',)", "('revenue_instance', 'user')") revenue ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('revenue_instance', 'user')") revenue_all_time ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('user',)") active_listings ['JOINED', 'METRIC'] +('listings_latest',) ("('user',)", "('user',)") archived_users ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('user',)") current_account_balance_by_user ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('user',)") identity_verifications ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('user',)") largest_listing ['JOINED', 'METRIC'] @@ -188,6 +189,7 @@ Model Join-Path Entity Links ('listings_latest',) ("('user',)", "('user',)") revenue ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('user',)") revenue_all_time ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('user',)") smallest_listing ['JOINED', 'METRIC'] +('listings_latest',) ("('user',)", "('user',)") subdaily_join_to_time_spine_metric ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('user',)") total_account_balance_first_day ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('user',)") views ['JOINED', 'METRIC'] ('listings_latest',) ("('user',)", "('user',)") visit_buy_conversion_rate ['JOINED', 'METRIC'] diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/tuple/test_linkable_elements_for_no_metrics_query__result0.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/tuple/test_linkable_elements_for_no_metrics_query__result0.txt index 8d687dd5cd..6f9396a6e5 100644 --- a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/tuple/test_linkable_elements_for_no_metrics_query__result0.txt +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/tuple/test_linkable_elements_for_no_metrics_query__result0.txt @@ -88,6 +88,7 @@ 'company__listing__user__company__views_times_booking_value', 'company__user', 'company__user__company__active_listings', + 'company__user__company__archived_users', 'company__user__company__current_account_balance_by_user', 'company__user__company__identity_verifications', 'company__user__company__largest_listing', @@ -99,6 +100,7 @@ 'company__user__company__revenue', 'company__user__company__revenue_all_time', 'company__user__company__smallest_listing', + 'company__user__company__subdaily_join_to_time_spine_metric', 'company__user__company__total_account_balance_first_day', 'company__user__company__views', 'company__user__company__visit_buy_conversion_rate', @@ -452,6 +454,7 @@ 'user__archived_at__extract_quarter', 'user__archived_at__extract_year', 'user__archived_at__hour', + 'user__archived_users', 'user__bio_added_ts__extract_day', 'user__bio_added_ts__extract_dow', 'user__bio_added_ts__extract_doy', @@ -568,6 +571,7 @@ 'user__revenue_instance__user__revenue', 'user__revenue_instance__user__revenue_all_time', 'user__smallest_listing', + 'user__subdaily_join_to_time_spine_metric', 'user__total_account_balance_first_day', 'user__verification__user__identity_verifications', 'user__view__user__views', diff --git a/tests_metricflow/integration/test_cases/itest_cumulative_metric.yaml b/tests_metricflow/integration/test_cases/itest_cumulative_metric.yaml index 71c4cac228..36551e25e9 100644 --- a/tests_metricflow/integration/test_cases/itest_cumulative_metric.yaml +++ b/tests_metricflow/integration/test_cases/itest_cumulative_metric.yaml @@ -592,3 +592,43 @@ integration_test: , metric_time__year , t2mr ) subq_9 +--- +integration_test: + name: subdaily_cumulative_window_metric + description: test a subdaily cumulative window metric + model: SIMPLE_MODEL + metrics: ["subdaily_cumulative_window_metric"] + group_bys: ["metric_time__hour"] + check_query: | + SELECT + subq_3.ts AS metric_time__hour + , SUM(subq_1.archived_users) AS subdaily_cumulative_window_metric + FROM {{ source_schema }}.mf_time_spine_hour subq_3 + INNER JOIN ( + SELECT + {{ render_date_trunc("archived_at", TimeGranularity.HOUR) }} AS metric_time__hour + , 1 AS archived_users + FROM {{ source_schema }}.dim_users + ) subq_1 + ON (subq_1.metric_time__hour <= subq_3.ts) AND (subq_1.metric_time__hour > {{ render_date_sub("subq_3", "Ts", 3, TimeGranularity.HOUR) }}) + GROUP BY subq_3.ts +--- +integration_test: + name: subdaily_cumulative_grain_to_date_metric + description: test a subdaily cumulative grain_to_date metric + model: SIMPLE_MODEL + metrics: ["subdaily_cumulative_grain_to_date_metric"] + group_bys: ["metric_time__hour"] + check_query: | + SELECT + subq_3.ts AS metric_time__hour + , SUM(subq_1.archived_users) AS subdaily_cumulative_grain_to_date_metric + FROM {{ source_schema }}.mf_time_spine_hour subq_3 + INNER JOIN ( + SELECT + {{ render_date_trunc("archived_at", TimeGranularity.HOUR) }} AS metric_time__hour + , 1 AS archived_users + FROM {{ source_schema }}.dim_users + ) subq_1 + ON (subq_1.metric_time__hour <= subq_3.ts) AND (subq_1.metric_time__hour >= {{ render_date_trunc("subq_3.ts", TimeGranularity.HOUR) }}) + GROUP BY subq_3.ts diff --git a/tests_metricflow/integration/test_cases/itest_metrics.yaml b/tests_metricflow/integration/test_cases/itest_metrics.yaml index 0036ed5587..343806ffb4 100644 --- a/tests_metricflow/integration/test_cases/itest_metrics.yaml +++ b/tests_metricflow/integration/test_cases/itest_metrics.yaml @@ -2265,3 +2265,68 @@ integration_test: ) GROUP BY subq_8.user__last_login_ts__minute +--- +integration_test: + name: subdaily_offset_window_metric + description: test a subdaily offset window metric + model: SIMPLE_MODEL + metrics: ["subdaily_offset_window_metric"] + group_bys: ["metric_time__hour"] + check_query: | + SELECT + subq_3.ts AS metric_time__hour + , SUM(subq_1.archived_users) AS subdaily_offset_window_metric + FROM {{ source_schema }}.mf_time_spine_hour subq_3 + INNER JOIN ( + SELECT + {{ render_date_trunc("archived_at", TimeGranularity.HOUR) }} AS metric_time__hour + , 1 AS archived_users + FROM {{ source_schema }}.dim_users + ) subq_1 + ON {{ render_date_sub("subq_3", "ts", 1, TimeGranularity.HOUR) }} = subq_1.metric_time__hour + GROUP BY subq_3.ts +--- +integration_test: + name: subdaily_offset_grain_to_date_metric + description: test a subdaily offset to grain metric + model: SIMPLE_MODEL + metrics: ["subdaily_offset_grain_to_date_metric"] + group_bys: ["metric_time__hour"] + check_query: | + SELECT + subq_3.ts AS metric_time__hour + , SUM(subq_1.archived_users) AS subdaily_offset_grain_to_date_metric + FROM {{ source_schema }}.mf_time_spine_hour subq_3 + INNER JOIN ( + SELECT + {{ render_date_trunc("archived_at", TimeGranularity.HOUR) }} AS metric_time__hour + , 1 AS archived_users + FROM {{ source_schema }}.dim_users + ) subq_1 + ON {{ render_date_trunc("subq_3.ts", TimeGranularity.HOUR) }} = subq_1.metric_time__hour + GROUP BY subq_3.ts +--- +integration_test: + name: subdaily_join_to_time_spine_metric + description: test a subdaily join to time spine metric + model: SIMPLE_MODEL + metrics: ["subdaily_join_to_time_spine_metric"] + group_bys: ["metric_time__hour"] + check_query: | + SELECT + subq_5.ts AS metric_time__hour + , subq_3.archived_users AS subdaily_join_to_time_spine_metric + FROM {{ source_schema }}.mf_time_spine_hour subq_5 + LEFT OUTER JOIN ( + SELECT + metric_time__hour + , SUM(archived_users) AS archived_users + FROM ( + SELECT + {{ render_date_trunc("archived_at", TimeGranularity.HOUR) }} AS metric_time__hour + , 1 AS archived_users + FROM {{ source_schema }}.dim_users + ) subq_2 + GROUP BY metric_time__hour + ) subq_3 + ON subq_5.ts = subq_3.metric_time__hour diff --git a/tests_metricflow/query_rendering/test_granularity_date_part_rendering.py b/tests_metricflow/query_rendering/test_granularity_date_part_rendering.py index 164815fd64..3391e5456f 100644 --- a/tests_metricflow/query_rendering/test_granularity_date_part_rendering.py +++ b/tests_metricflow/query_rendering/test_granularity_date_part_rendering.py @@ -212,3 +212,118 @@ def test_simple_metric_with_joined_sub_daily_dimension( # noqa: D103 dataflow_plan_builder=dataflow_plan_builder, query_spec=query_spec, ) + + +@pytest.mark.sql_engine_snapshot +def test_subdaily_cumulative_window_metric( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + query_spec = MetricFlowQuerySpec( + metric_specs=(MetricSpec("subdaily_cumulative_window_metric"),), + time_dimension_specs=(DataSet.metric_time_dimension_spec(time_granularity=TimeGranularity.HOUR),), + ) + + render_and_check( + request=request, + mf_test_configuration=mf_test_configuration, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + dataflow_plan_builder=dataflow_plan_builder, + query_spec=query_spec, + ) + + +@pytest.mark.sql_engine_snapshot +def test_subdaily_cumulative_grain_to_date_metric( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + query_spec = MetricFlowQuerySpec( + metric_specs=(MetricSpec("subdaily_cumulative_grain_to_date_metric"),), + time_dimension_specs=(DataSet.metric_time_dimension_spec(time_granularity=TimeGranularity.HOUR),), + ) + + render_and_check( + request=request, + mf_test_configuration=mf_test_configuration, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + dataflow_plan_builder=dataflow_plan_builder, + query_spec=query_spec, + ) + + +@pytest.mark.sql_engine_snapshot +def test_subdaily_offset_window_metric( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + query_spec = MetricFlowQuerySpec( + metric_specs=(MetricSpec("subdaily_offset_window_metric"),), + time_dimension_specs=(DataSet.metric_time_dimension_spec(time_granularity=TimeGranularity.HOUR),), + ) + + render_and_check( + request=request, + mf_test_configuration=mf_test_configuration, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + dataflow_plan_builder=dataflow_plan_builder, + query_spec=query_spec, + ) + + +@pytest.mark.sql_engine_snapshot +def test_subdaily_offset_to_grain_metric( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + query_spec = MetricFlowQuerySpec( + metric_specs=(MetricSpec("subdaily_offset_grain_to_date_metric"),), + time_dimension_specs=(DataSet.metric_time_dimension_spec(time_granularity=TimeGranularity.HOUR),), + ) + + render_and_check( + request=request, + mf_test_configuration=mf_test_configuration, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + dataflow_plan_builder=dataflow_plan_builder, + query_spec=query_spec, + ) + + +@pytest.mark.sql_engine_snapshot +def test_subdaily_join_to_time_spine_metric( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + dataflow_plan_builder: DataflowPlanBuilder, + dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter, + sql_client: SqlClient, +) -> None: + query_spec = MetricFlowQuerySpec( + metric_specs=(MetricSpec("subdaily_join_to_time_spine_metric"),), + time_dimension_specs=(DataSet.metric_time_dimension_spec(time_granularity=TimeGranularity.HOUR),), + ) + + render_and_check( + request=request, + mf_test_configuration=mf_test_configuration, + dataflow_to_sql_converter=dataflow_to_sql_converter, + sql_client=sql_client, + dataflow_plan_builder=dataflow_plan_builder, + query_spec=query_spec, + ) diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml index 34342ed5c4..8793465e07 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml @@ -239,7 +239,7 @@ - + @@ -694,7 +694,7 @@ - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.xml index 714dda14f3..05827c801d 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.xml @@ -321,7 +321,7 @@ - + @@ -860,7 +860,7 @@ - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml index d93ede7dd6..4f1a1debb6 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml @@ -267,7 +267,7 @@ - + @@ -753,7 +753,7 @@ - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml index bf2e7fd549..0e47d15bbd 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml @@ -290,7 +290,7 @@ - + @@ -813,7 +813,7 @@ - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml index 60fbf4b0f4..f18c79eea4 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml @@ -242,7 +242,7 @@ - + @@ -697,7 +697,7 @@ - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml index e4c825e0bb..f63906f119 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml @@ -290,7 +290,7 @@ - + @@ -801,7 +801,7 @@ - + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml index 1b05350e56..dae988091d 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml @@ -115,7 +115,7 @@ - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml index 159530b266..6582795a6b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml @@ -2183,7 +2183,7 @@ - + diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index e698e92cef..064320f388 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1105,6 +1105,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_sub_daily_dimension__plan0.sql index 8d50d7a38a..e0ea1863ad 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_sub_daily_dimension__plan0.sql @@ -208,6 +208,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_sub_daily_dimension__plan0.sql index 2752c1396c..d3e3e850f8 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_sub_daily_dimension__plan0.sql @@ -5,6 +5,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0.sql new file mode 100644 index 0000000000..a9629ffe48 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_grain_to_date_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS user__ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS user__created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS user__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS user__last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS user__last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS user__last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS user__last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS user__last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS user__last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS user__last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS user__last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS user__bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS user__bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS user__bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS user__bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS user__bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS user__bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS user__bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS user__bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS user__last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS user__last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS user__last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS user__last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS user__last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS user__last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS user__last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS user__archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS user__archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS user__archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS user__archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS user__archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS user__archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour >= DATETIME_TRUNC(subq_2.metric_time__hour, hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql new file mode 100644 index 0000000000..c2c2880c4f --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATETIME_TRUNC(archived_at, hour) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour >= DATETIME_TRUNC(subq_10.ts, hour) + ) +GROUP BY + metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0.sql new file mode 100644 index 0000000000..837b1fb254 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_window_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS user__ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS user__created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS user__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS user__last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS user__last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS user__last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS user__last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS user__last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS user__last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS user__last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS user__last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS user__bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS user__bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS user__bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS user__bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS user__bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS user__bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS user__bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS user__bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS user__last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS user__last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS user__last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS user__last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS user__last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS user__last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS user__last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS user__archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS user__archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS user__archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS user__archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS user__archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS user__archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour > DATE_SUB(CAST(subq_2.metric_time__hour AS DATETIME), INTERVAL 3 hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..d5b1b0bc66 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATETIME_TRUNC(archived_at, hour) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour > DATE_SUB(CAST(subq_10.ts AS DATETIME), INTERVAL 3 hour) + ) +GROUP BY + metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0.sql new file mode 100644 index 0000000000..371083d74c --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -0,0 +1,410 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_join_to_time_spine_metric +FROM ( + -- Join to Time Spine Dataset + SELECT + subq_4.metric_time__hour AS metric_time__hour + , subq_3.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_5.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_5 + ) subq_4 + LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_2.metric_time__hour + , SUM(subq_2.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_1.metric_time__hour + , subq_1.archived_users + FROM ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS user__ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS user__created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS user__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS user__last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS user__last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS user__last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS user__last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS user__last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS user__last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS user__last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS user__last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS user__bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS user__bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS user__bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS user__bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS user__bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS user__bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS user__bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS user__bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS user__last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS user__last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS user__last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS user__last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS user__last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS user__last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS user__last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS user__archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS user__archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS user__archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS user__archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS user__archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS user__archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + metric_time__hour + ) subq_3 + ON + subq_4.metric_time__hour = subq_3.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql new file mode 100644 index 0000000000..97859a3220 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -0,0 +1,25 @@ +-- Join to Time Spine Dataset +-- Compute Metrics via Expressions +SELECT + subq_12.ts AS metric_time__hour + , subq_10.archived_users AS subdaily_join_to_time_spine_metric +FROM ***************************.mf_time_spine_hour subq_12 +LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + metric_time__hour + , SUM(archived_users) AS archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + DATETIME_TRUNC(archived_at, hour) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + GROUP BY + metric_time__hour +) subq_10 +ON + subq_12.ts = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql new file mode 100644 index 0000000000..2dc17f03a4 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATETIME_TRUNC(subq_2.metric_time__hour, day) AS metric_time__day + , DATETIME_TRUNC(subq_2.metric_time__hour, isoweek) AS metric_time__week + , DATETIME_TRUNC(subq_2.metric_time__hour, month) AS metric_time__month + , DATETIME_TRUNC(subq_2.metric_time__hour, quarter) AS metric_time__quarter + , DATETIME_TRUNC(subq_2.metric_time__hour, year) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , IF(EXTRACT(dayofweek FROM subq_2.metric_time__hour) = 1, 7, EXTRACT(dayofweek FROM subq_2.metric_time__hour) - 1) AS metric_time__extract_dow + , EXTRACT(dayofyear FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS user__ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS user__created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS user__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS user__last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS user__last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS user__last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS user__last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS user__last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS user__last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS user__last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS user__last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS user__bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS user__bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS user__bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS user__bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS user__bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS user__bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS user__bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS user__bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS user__last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS user__last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS user__last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS user__last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS user__last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS user__last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS user__last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS user__archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS user__archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS user__archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS user__archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS user__archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS user__archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATETIME_TRUNC(subq_2.metric_time__hour, hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0_optimized.sql new file mode 100644 index 0000000000..82f176cfbe --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATETIME_TRUNC(archived_at, hour) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATETIME_TRUNC(subq_11.ts, hour) = subq_9.metric_time__hour + GROUP BY + metric_time__hour +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql new file mode 100644 index 0000000000..f25cd83b4a --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATETIME_TRUNC(subq_2.metric_time__hour, day) AS metric_time__day + , DATETIME_TRUNC(subq_2.metric_time__hour, isoweek) AS metric_time__week + , DATETIME_TRUNC(subq_2.metric_time__hour, month) AS metric_time__month + , DATETIME_TRUNC(subq_2.metric_time__hour, quarter) AS metric_time__quarter + , DATETIME_TRUNC(subq_2.metric_time__hour, year) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , IF(EXTRACT(dayofweek FROM subq_2.metric_time__hour) = 1, 7, EXTRACT(dayofweek FROM subq_2.metric_time__hour) - 1) AS metric_time__extract_dow + , EXTRACT(dayofyear FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds, year) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds) - 1) AS user__ds__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, year) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.created_at) - 1) AS user__created_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, year) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.ds_partitioned) - 1) AS user__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS user__last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS user__last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS user__last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS user__last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS user__last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS user__last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS user__last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS user__last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS user__bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS user__bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS user__bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS user__bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS user__bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS user__bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS user__bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS user__bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS user__last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS user__last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS user__last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS user__last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS user__last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS user__last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS user__last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS user__archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS user__archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS user__archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS user__archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS user__archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS user__archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_SUB(CAST(subq_2.metric_time__hour AS DATETIME), INTERVAL 1 hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..ee3ca01a8b --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATETIME_TRUNC(archived_at, hour) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATE_SUB(CAST(subq_11.ts AS DATETIME), INTERVAL 1 hour) = subq_9.metric_time__hour + GROUP BY + metric_time__hour +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 1eff3f6090..080cda4587 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1105,6 +1105,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_sub_daily_dimension__plan0.sql index 182f443356..6957307244 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_sub_daily_dimension__plan0.sql @@ -208,6 +208,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_sub_daily_dimension__plan0.sql index 01d34c71b7..85f046d53e 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_sub_daily_dimension__plan0.sql @@ -5,6 +5,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0.sql new file mode 100644 index 0000000000..79da25522b --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_grain_to_date_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour >= DATE_TRUNC('hour', subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql new file mode 100644 index 0000000000..fe834fa9e6 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0.sql new file mode 100644 index 0000000000..bf8eb1e375 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_window_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour > DATEADD(hour, -3, subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..383af54854 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour > DATEADD(hour, -3, subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0.sql new file mode 100644 index 0000000000..7968c03d70 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -0,0 +1,410 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_join_to_time_spine_metric +FROM ( + -- Join to Time Spine Dataset + SELECT + subq_4.metric_time__hour AS metric_time__hour + , subq_3.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_5.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_5 + ) subq_4 + LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_2.metric_time__hour + , SUM(subq_2.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_1.metric_time__hour + , subq_1.archived_users + FROM ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__hour + ) subq_3 + ON + subq_4.metric_time__hour = subq_3.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql new file mode 100644 index 0000000000..44763c6b6e --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -0,0 +1,25 @@ +-- Join to Time Spine Dataset +-- Compute Metrics via Expressions +SELECT + subq_12.ts AS metric_time__hour + , subq_10.archived_users AS subdaily_join_to_time_spine_metric +FROM ***************************.mf_time_spine_hour subq_12 +LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + metric_time__hour + , SUM(archived_users) AS archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + GROUP BY + metric_time__hour +) subq_10 +ON + subq_12.ts = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql new file mode 100644 index 0000000000..656b76a7f9 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('hour', subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0_optimized.sql new file mode 100644 index 0000000000..2679104380 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql new file mode 100644 index 0000000000..7f24f79da5 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATEADD(hour, -1, subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..c1f150dd0c --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATEADD(hour, -1, subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 2319c7e1f9..c2505892cd 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1105,6 +1105,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_metric_with_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_metric_with_sub_daily_dimension__plan0.sql index 712a3c0a08..e1d3b4b02c 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_metric_with_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_simple_metric_with_sub_daily_dimension__plan0.sql @@ -208,6 +208,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_sub_daily_dimension__plan0.sql index 4784321669..e10224debe 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_sub_daily_dimension__plan0.sql @@ -5,6 +5,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_grain_to_date_metric__plan0.sql new file mode 100644 index 0000000000..1a252f2ebe --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_grain_to_date_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour >= DATE_TRUNC('hour', subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql new file mode 100644 index 0000000000..fe834fa9e6 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_window_metric__plan0.sql new file mode 100644 index 0000000000..a18b954931 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_window_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_window_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour > subq_2.metric_time__hour - INTERVAL 3 hour + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..f031751858 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour > subq_10.ts - INTERVAL 3 hour + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_join_to_time_spine_metric__plan0.sql new file mode 100644 index 0000000000..fe488e80ff --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -0,0 +1,410 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_join_to_time_spine_metric +FROM ( + -- Join to Time Spine Dataset + SELECT + subq_4.metric_time__hour AS metric_time__hour + , subq_3.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_5.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_5 + ) subq_4 + LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_2.metric_time__hour + , SUM(subq_2.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_1.metric_time__hour + , subq_1.archived_users + FROM ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__hour + ) subq_3 + ON + subq_4.metric_time__hour = subq_3.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql new file mode 100644 index 0000000000..44763c6b6e --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -0,0 +1,25 @@ +-- Join to Time Spine Dataset +-- Compute Metrics via Expressions +SELECT + subq_12.ts AS metric_time__hour + , subq_10.archived_users AS subdaily_join_to_time_spine_metric +FROM ***************************.mf_time_spine_hour subq_12 +LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + metric_time__hour + , SUM(archived_users) AS archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + GROUP BY + metric_time__hour +) subq_10 +ON + subq_12.ts = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql new file mode 100644 index 0000000000..d30be670b4 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(isodow FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('hour', subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0_optimized.sql new file mode 100644 index 0000000000..2679104380 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql new file mode 100644 index 0000000000..9a1d976fcd --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(isodow FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + subq_2.metric_time__hour - INTERVAL 1 hour = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..66fbdfb392 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + subq_11.ts - INTERVAL 1 hour = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 2319c7e1f9..c2505892cd 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1105,6 +1105,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_sub_daily_dimension__plan0.sql index 712a3c0a08..e1d3b4b02c 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_sub_daily_dimension__plan0.sql @@ -208,6 +208,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_sub_daily_dimension__plan0.sql index 4784321669..e10224debe 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_sub_daily_dimension__plan0.sql @@ -5,6 +5,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0.sql new file mode 100644 index 0000000000..1a252f2ebe --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_grain_to_date_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour >= DATE_TRUNC('hour', subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql new file mode 100644 index 0000000000..fe834fa9e6 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0.sql new file mode 100644 index 0000000000..c4cdff003c --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_window_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour > subq_2.metric_time__hour - MAKE_INTERVAL(hours => 3) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..86828264bb --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour > subq_10.ts - MAKE_INTERVAL(hours => 3) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0.sql new file mode 100644 index 0000000000..fe488e80ff --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -0,0 +1,410 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_join_to_time_spine_metric +FROM ( + -- Join to Time Spine Dataset + SELECT + subq_4.metric_time__hour AS metric_time__hour + , subq_3.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_5.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_5 + ) subq_4 + LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_2.metric_time__hour + , SUM(subq_2.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_1.metric_time__hour + , subq_1.archived_users + FROM ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__hour + ) subq_3 + ON + subq_4.metric_time__hour = subq_3.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql new file mode 100644 index 0000000000..44763c6b6e --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -0,0 +1,25 @@ +-- Join to Time Spine Dataset +-- Compute Metrics via Expressions +SELECT + subq_12.ts AS metric_time__hour + , subq_10.archived_users AS subdaily_join_to_time_spine_metric +FROM ***************************.mf_time_spine_hour subq_12 +LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + metric_time__hour + , SUM(archived_users) AS archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + GROUP BY + metric_time__hour +) subq_10 +ON + subq_12.ts = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql new file mode 100644 index 0000000000..d30be670b4 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(isodow FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('hour', subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0_optimized.sql new file mode 100644 index 0000000000..2679104380 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql new file mode 100644 index 0000000000..86e2ae8260 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(isodow FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + subq_2.metric_time__hour - MAKE_INTERVAL(hours => 1) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..4481a4f63b --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + subq_11.ts - MAKE_INTERVAL(hours => 1) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 29201c396e..9982f51ad0 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1105,6 +1105,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_sub_daily_dimension__plan0.sql index 2fb720e755..efda16c776 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_sub_daily_dimension__plan0.sql @@ -208,6 +208,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_sub_daily_dimension__plan0.sql index e420ab9005..02932acf3f 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_sub_daily_dimension__plan0.sql @@ -5,6 +5,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0.sql new file mode 100644 index 0000000000..4ef0598915 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_grain_to_date_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour >= DATE_TRUNC('hour', subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql new file mode 100644 index 0000000000..fe834fa9e6 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0.sql new file mode 100644 index 0000000000..1d47d605da --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_window_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour > DATEADD(hour, -3, subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..383af54854 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour > DATEADD(hour, -3, subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0.sql new file mode 100644 index 0000000000..b20cb0d168 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -0,0 +1,410 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_join_to_time_spine_metric +FROM ( + -- Join to Time Spine Dataset + SELECT + subq_4.metric_time__hour AS metric_time__hour + , subq_3.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_5.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_5 + ) subq_4 + LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_2.metric_time__hour + , SUM(subq_2.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_1.metric_time__hour + , subq_1.archived_users + FROM ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__hour + ) subq_3 + ON + subq_4.metric_time__hour = subq_3.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql new file mode 100644 index 0000000000..44763c6b6e --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -0,0 +1,25 @@ +-- Join to Time Spine Dataset +-- Compute Metrics via Expressions +SELECT + subq_12.ts AS metric_time__hour + , subq_10.archived_users AS subdaily_join_to_time_spine_metric +FROM ***************************.mf_time_spine_hour subq_12 +LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + metric_time__hour + , SUM(archived_users) AS archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + GROUP BY + metric_time__hour +) subq_10 +ON + subq_12.ts = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql new file mode 100644 index 0000000000..3cbe377614 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , CASE WHEN EXTRACT(dow FROM subq_2.metric_time__hour) = 0 THEN EXTRACT(dow FROM subq_2.metric_time__hour) + 7 ELSE EXTRACT(dow FROM subq_2.metric_time__hour) END AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('hour', subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0_optimized.sql new file mode 100644 index 0000000000..2679104380 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql new file mode 100644 index 0000000000..06128e25e6 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , CASE WHEN EXTRACT(dow FROM subq_2.metric_time__hour) = 0 THEN EXTRACT(dow FROM subq_2.metric_time__hour) + 7 ELSE EXTRACT(dow FROM subq_2.metric_time__hour) END AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds) END AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.created_at) END AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.ds_partitioned) END AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATEADD(hour, -1, subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..c1f150dd0c --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATEADD(hour, -1, subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 86a9dc583b..06117ebe55 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1105,6 +1105,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_sub_daily_dimension__plan0.sql index 537ea209e7..e86f504fd3 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_sub_daily_dimension__plan0.sql @@ -208,6 +208,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_sub_daily_dimension__plan0.sql index c743b8ab7f..0c6511a2c8 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_sub_daily_dimension__plan0.sql @@ -5,6 +5,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0.sql new file mode 100644 index 0000000000..23c7ebf08d --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_grain_to_date_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour >= DATE_TRUNC('hour', subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql new file mode 100644 index 0000000000..fe834fa9e6 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0.sql new file mode 100644 index 0000000000..3f7f85a176 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_window_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour > DATEADD(hour, -3, subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..383af54854 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour > DATEADD(hour, -3, subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0.sql new file mode 100644 index 0000000000..1da20491ef --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -0,0 +1,410 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_join_to_time_spine_metric +FROM ( + -- Join to Time Spine Dataset + SELECT + subq_4.metric_time__hour AS metric_time__hour + , subq_3.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_5.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_5 + ) subq_4 + LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_2.metric_time__hour + , SUM(subq_2.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_1.metric_time__hour + , subq_1.archived_users + FROM ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__hour + ) subq_3 + ON + subq_4.metric_time__hour = subq_3.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql new file mode 100644 index 0000000000..44763c6b6e --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -0,0 +1,25 @@ +-- Join to Time Spine Dataset +-- Compute Metrics via Expressions +SELECT + subq_12.ts AS metric_time__hour + , subq_10.archived_users AS subdaily_join_to_time_spine_metric +FROM ***************************.mf_time_spine_hour subq_12 +LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + metric_time__hour + , SUM(archived_users) AS archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + GROUP BY + metric_time__hour +) subq_10 +ON + subq_12.ts = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql new file mode 100644 index 0000000000..b127b9b063 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(dayofweekiso FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('hour', subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0_optimized.sql new file mode 100644 index 0000000000..2679104380 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql new file mode 100644 index 0000000000..af61bc2907 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(dayofweekiso FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATEADD(hour, -1, subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..c1f150dd0c --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATEADD(hour, -1, subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 215741cd3e..667fbfe1e6 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1105,6 +1105,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_sub_daily_dimension__plan0.sql index c5e5638664..eeba1c67bf 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_sub_daily_dimension__plan0.sql @@ -208,6 +208,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_sub_daily_dimension__plan0.sql index b7a93f6d5a..493add2b99 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_sub_daily_dimension__plan0.sql @@ -5,6 +5,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0.sql new file mode 100644 index 0000000000..b1e2e5d581 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_grain_to_date_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour >= DATE_TRUNC('hour', subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql new file mode 100644 index 0000000000..fe834fa9e6 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0.sql new file mode 100644 index 0000000000..56dd014810 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0.sql @@ -0,0 +1,602 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_cumulative_window_metric +FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join Self Over Time Range + SELECT + subq_2.metric_time__hour AS metric_time__hour + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.metric_time__day AS metric_time__day + , subq_1.metric_time__week AS metric_time__week + , subq_1.metric_time__month AS metric_time__month + , subq_1.metric_time__quarter AS metric_time__quarter + , subq_1.metric_time__year AS metric_time__year + , subq_1.metric_time__extract_year AS metric_time__extract_year + , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_1.metric_time__extract_day AS metric_time__extract_day + , subq_1.metric_time__extract_dow AS metric_time__extract_dow + , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__hour <= subq_2.metric_time__hour + ) AND ( + subq_1.metric_time__hour > DATE_ADD('hour', -3, subq_2.metric_time__hour) + ) + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..38bf90d047 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -0,0 +1,24 @@ +-- Join Self Over Time Range +-- Pass Only Elements: ['archived_users', 'metric_time__hour'] +-- Aggregate Measures +-- Compute Metrics via Expressions +SELECT + subq_10.ts AS metric_time__hour + , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric +FROM ***************************.mf_time_spine_hour subq_10 +INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 +) subq_8 +ON + ( + subq_8.metric_time__hour <= subq_10.ts + ) AND ( + subq_8.metric_time__hour > DATE_ADD('hour', -3, subq_10.ts) + ) +GROUP BY + subq_10.ts diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0.sql new file mode 100644 index 0000000000..8d782a8799 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -0,0 +1,410 @@ +-- Compute Metrics via Expressions +SELECT + subq_6.metric_time__hour + , subq_6.archived_users AS subdaily_join_to_time_spine_metric +FROM ( + -- Join to Time Spine Dataset + SELECT + subq_4.metric_time__hour AS metric_time__hour + , subq_3.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_5.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_5 + ) subq_4 + LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_2.metric_time__hour + , SUM(subq_2.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_1.metric_time__hour + , subq_1.archived_users + FROM ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ) subq_2 + GROUP BY + subq_2.metric_time__hour + ) subq_3 + ON + subq_4.metric_time__hour = subq_3.metric_time__hour +) subq_6 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql new file mode 100644 index 0000000000..44763c6b6e --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -0,0 +1,25 @@ +-- Join to Time Spine Dataset +-- Compute Metrics via Expressions +SELECT + subq_12.ts AS metric_time__hour + , subq_10.archived_users AS subdaily_join_to_time_spine_metric +FROM ***************************.mf_time_spine_hour subq_12 +LEFT OUTER JOIN ( + -- Aggregate Measures + SELECT + metric_time__hour + , SUM(archived_users) AS archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + GROUP BY + metric_time__hour +) subq_10 +ON + subq_12.ts = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql new file mode 100644 index 0000000000..3f01692015 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(DAY_OF_WEEK FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('hour', subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0_optimized.sql new file mode 100644 index 0000000000..2679104380 --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_grain_to_date_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0.sql new file mode 100644 index 0000000000..cbf1be1e9d --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0.sql @@ -0,0 +1,604 @@ +-- Compute Metrics via Expressions +SELECT + subq_7.metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Compute Metrics via Expressions + SELECT + subq_6.metric_time__hour + , subq_6.archived_users + FROM ( + -- Aggregate Measures + SELECT + subq_5.metric_time__hour + , SUM(subq_5.archived_users) AS archived_users + FROM ( + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + SELECT + subq_4.metric_time__hour + , subq_4.archived_users + FROM ( + -- Join to Time Spine Dataset + SELECT + subq_2.metric_time__hour AS metric_time__hour + , DATE_TRUNC('day', subq_2.metric_time__hour) AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__hour) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__hour) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__hour) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__hour) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__hour) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__hour) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__hour) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__hour) AS metric_time__extract_day + , EXTRACT(DAY_OF_WEEK FROM subq_2.metric_time__hour) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__hour) AS metric_time__extract_doy + , subq_1.ds__day AS ds__day + , subq_1.ds__week AS ds__week + , subq_1.ds__month AS ds__month + , subq_1.ds__quarter AS ds__quarter + , subq_1.ds__year AS ds__year + , subq_1.ds__extract_year AS ds__extract_year + , subq_1.ds__extract_quarter AS ds__extract_quarter + , subq_1.ds__extract_month AS ds__extract_month + , subq_1.ds__extract_day AS ds__extract_day + , subq_1.ds__extract_dow AS ds__extract_dow + , subq_1.ds__extract_doy AS ds__extract_doy + , subq_1.created_at__day AS created_at__day + , subq_1.created_at__week AS created_at__week + , subq_1.created_at__month AS created_at__month + , subq_1.created_at__quarter AS created_at__quarter + , subq_1.created_at__year AS created_at__year + , subq_1.created_at__extract_year AS created_at__extract_year + , subq_1.created_at__extract_quarter AS created_at__extract_quarter + , subq_1.created_at__extract_month AS created_at__extract_month + , subq_1.created_at__extract_day AS created_at__extract_day + , subq_1.created_at__extract_dow AS created_at__extract_dow + , subq_1.created_at__extract_doy AS created_at__extract_doy + , subq_1.ds_partitioned__day AS ds_partitioned__day + , subq_1.ds_partitioned__week AS ds_partitioned__week + , subq_1.ds_partitioned__month AS ds_partitioned__month + , subq_1.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_1.ds_partitioned__year AS ds_partitioned__year + , subq_1.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_1.last_profile_edit_ts__millisecond AS last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second AS last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute AS last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour AS last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day AS last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week AS last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month AS last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter AS last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year AS last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year AS last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter AS last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month AS last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day AS last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow AS last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy AS last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second AS bio_added_ts__second + , subq_1.bio_added_ts__minute AS bio_added_ts__minute + , subq_1.bio_added_ts__hour AS bio_added_ts__hour + , subq_1.bio_added_ts__day AS bio_added_ts__day + , subq_1.bio_added_ts__week AS bio_added_ts__week + , subq_1.bio_added_ts__month AS bio_added_ts__month + , subq_1.bio_added_ts__quarter AS bio_added_ts__quarter + , subq_1.bio_added_ts__year AS bio_added_ts__year + , subq_1.bio_added_ts__extract_year AS bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter AS bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month AS bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day AS bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow AS bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy AS bio_added_ts__extract_doy + , subq_1.last_login_ts__minute AS last_login_ts__minute + , subq_1.last_login_ts__hour AS last_login_ts__hour + , subq_1.last_login_ts__day AS last_login_ts__day + , subq_1.last_login_ts__week AS last_login_ts__week + , subq_1.last_login_ts__month AS last_login_ts__month + , subq_1.last_login_ts__quarter AS last_login_ts__quarter + , subq_1.last_login_ts__year AS last_login_ts__year + , subq_1.last_login_ts__extract_year AS last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter AS last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month AS last_login_ts__extract_month + , subq_1.last_login_ts__extract_day AS last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow AS last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy AS last_login_ts__extract_doy + , subq_1.archived_at__hour AS archived_at__hour + , subq_1.archived_at__day AS archived_at__day + , subq_1.archived_at__week AS archived_at__week + , subq_1.archived_at__month AS archived_at__month + , subq_1.archived_at__quarter AS archived_at__quarter + , subq_1.archived_at__year AS archived_at__year + , subq_1.archived_at__extract_year AS archived_at__extract_year + , subq_1.archived_at__extract_quarter AS archived_at__extract_quarter + , subq_1.archived_at__extract_month AS archived_at__extract_month + , subq_1.archived_at__extract_day AS archived_at__extract_day + , subq_1.archived_at__extract_dow AS archived_at__extract_dow + , subq_1.archived_at__extract_doy AS archived_at__extract_doy + , subq_1.user__ds__day AS user__ds__day + , subq_1.user__ds__week AS user__ds__week + , subq_1.user__ds__month AS user__ds__month + , subq_1.user__ds__quarter AS user__ds__quarter + , subq_1.user__ds__year AS user__ds__year + , subq_1.user__ds__extract_year AS user__ds__extract_year + , subq_1.user__ds__extract_quarter AS user__ds__extract_quarter + , subq_1.user__ds__extract_month AS user__ds__extract_month + , subq_1.user__ds__extract_day AS user__ds__extract_day + , subq_1.user__ds__extract_dow AS user__ds__extract_dow + , subq_1.user__ds__extract_doy AS user__ds__extract_doy + , subq_1.user__created_at__day AS user__created_at__day + , subq_1.user__created_at__week AS user__created_at__week + , subq_1.user__created_at__month AS user__created_at__month + , subq_1.user__created_at__quarter AS user__created_at__quarter + , subq_1.user__created_at__year AS user__created_at__year + , subq_1.user__created_at__extract_year AS user__created_at__extract_year + , subq_1.user__created_at__extract_quarter AS user__created_at__extract_quarter + , subq_1.user__created_at__extract_month AS user__created_at__extract_month + , subq_1.user__created_at__extract_day AS user__created_at__extract_day + , subq_1.user__created_at__extract_dow AS user__created_at__extract_dow + , subq_1.user__created_at__extract_doy AS user__created_at__extract_doy + , subq_1.user__ds_partitioned__day AS user__ds_partitioned__day + , subq_1.user__ds_partitioned__week AS user__ds_partitioned__week + , subq_1.user__ds_partitioned__month AS user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year AS user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second AS user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute AS user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour AS user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day AS user__bio_added_ts__day + , subq_1.user__bio_added_ts__week AS user__bio_added_ts__week + , subq_1.user__bio_added_ts__month AS user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year AS user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute AS user__last_login_ts__minute + , subq_1.user__last_login_ts__hour AS user__last_login_ts__hour + , subq_1.user__last_login_ts__day AS user__last_login_ts__day + , subq_1.user__last_login_ts__week AS user__last_login_ts__week + , subq_1.user__last_login_ts__month AS user__last_login_ts__month + , subq_1.user__last_login_ts__quarter AS user__last_login_ts__quarter + , subq_1.user__last_login_ts__year AS user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour AS user__archived_at__hour + , subq_1.user__archived_at__day AS user__archived_at__day + , subq_1.user__archived_at__week AS user__archived_at__week + , subq_1.user__archived_at__month AS user__archived_at__month + , subq_1.user__archived_at__quarter AS user__archived_at__quarter + , subq_1.user__archived_at__year AS user__archived_at__year + , subq_1.user__archived_at__extract_year AS user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month AS user__archived_at__extract_month + , subq_1.user__archived_at__extract_day AS user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow AS user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy AS user__archived_at__extract_doy + , subq_1.user AS user + , subq_1.home_state AS home_state + , subq_1.user__home_state AS user__home_state + , subq_1.archived_users AS archived_users + FROM ( + -- Time Spine + SELECT + subq_3.ts AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_3 + ) subq_2 + INNER JOIN ( + -- Metric Time Dimension 'archived_at' + SELECT + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users + FROM ( + -- Read Elements From Semantic Model 'users_ds_source' + SELECT + 1 AS new_users + , 1 AS archived_users + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS user__ds__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS user__ds__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds) AS user__ds__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds) AS user__ds__year + , EXTRACT(year FROM users_ds_source_src_28000.ds) AS user__ds__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds) AS user__ds__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds) AS user__ds__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds) AS user__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds) AS user__ds__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds) AS user__ds__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.created_at) AS user__created_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.created_at) AS user__created_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.created_at) AS user__created_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.created_at) AS user__created_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.created_at) AS user__created_at__year + , EXTRACT(year FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.created_at) AS user__created_at__extract_doy + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , DATE_TRUNC('week', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__week + , DATE_TRUNC('month', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__year + , EXTRACT(year FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__extract_doy + , users_ds_source_src_28000.home_state AS user__home_state + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_ADD('hour', -1, subq_2.metric_time__hour) = subq_1.metric_time__hour + ) subq_4 + ) subq_5 + GROUP BY + subq_5.metric_time__hour + ) subq_6 +) subq_7 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0_optimized.sql new file mode 100644 index 0000000000..70b55ba01d --- /dev/null +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -0,0 +1,26 @@ +-- Compute Metrics via Expressions +SELECT + metric_time__hour + , archived_users AS subdaily_offset_window_metric +FROM ( + -- Join to Time Spine Dataset + -- Pass Only Elements: ['archived_users', 'metric_time__hour'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + subq_11.ts AS metric_time__hour + , SUM(subq_9.archived_users) AS archived_users + FROM ***************************.mf_time_spine_hour subq_11 + INNER JOIN ( + -- Read Elements From Semantic Model 'users_ds_source' + -- Metric Time Dimension 'archived_at' + SELECT + DATE_TRUNC('hour', archived_at) AS metric_time__hour + , 1 AS archived_users + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_9 + ON + DATE_ADD('hour', -1, subq_11.ts) = subq_9.metric_time__hour + GROUP BY + subq_11.ts +) subq_15 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfp_0.xml index a8488b82d8..36a3aaae53 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfp_0.xml @@ -153,7 +153,7 @@ - + @@ -257,7 +257,7 @@ - + diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql index 7b94b46885..c8b50dbfa4 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql @@ -349,6 +349,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql index c9ffa81f2b..c98923aec3 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql @@ -349,6 +349,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql index 11f19b0691..9331570241 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql @@ -349,6 +349,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql index 11f19b0691..9331570241 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql @@ -349,6 +349,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql index ab3ae405c0..d6f8a697c9 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql @@ -349,6 +349,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql index d87df86a70..61d75185f0 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql @@ -349,6 +349,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql index be69bb3d8d..7d2a3efd92 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql @@ -349,6 +349,7 @@ FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT 1 AS new_users + , 1 AS archived_users , DATE_TRUNC('day', users_ds_source_src_28000.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_28000.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_28000.ds) AS ds__month