From 857a942b40255c2d4a614d27c76c237e50a33797 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Mon, 29 Jul 2024 17:55:08 -0700 Subject: [PATCH] Update SQL engine snapshots for new tests --- ...cumulative_grain_to_date_metric__plan0.sql | 602 +++++++++++++++++ ..._grain_to_date_metric__plan0_optimized.sql | 24 + ...bdaily_cumulative_window_metric__plan0.sql | 602 +++++++++++++++++ ...ulative_window_metric__plan0_optimized.sql | 24 + ...daily_join_to_time_spine_metric__plan0.sql | 410 ++++++++++++ ..._to_time_spine_metric__plan0_optimized.sql | 25 + ...subdaily_offset_to_grain_metric__plan0.sql | 604 ++++++++++++++++++ ...ffset_to_grain_metric__plan0_optimized.sql | 26 + ...t_subdaily_offset_window_metric__plan0.sql | 604 ++++++++++++++++++ ..._offset_window_metric__plan0_optimized.sql | 26 + ...cumulative_grain_to_date_metric__plan0.sql | 602 +++++++++++++++++ ..._grain_to_date_metric__plan0_optimized.sql | 24 + ...bdaily_cumulative_window_metric__plan0.sql | 602 +++++++++++++++++ ...ulative_window_metric__plan0_optimized.sql | 24 + ...daily_join_to_time_spine_metric__plan0.sql | 410 ++++++++++++ ..._to_time_spine_metric__plan0_optimized.sql | 25 + ...subdaily_offset_to_grain_metric__plan0.sql | 604 ++++++++++++++++++ ...ffset_to_grain_metric__plan0_optimized.sql | 26 + ...t_subdaily_offset_window_metric__plan0.sql | 604 ++++++++++++++++++ ..._offset_window_metric__plan0_optimized.sql | 26 + ...cumulative_grain_to_date_metric__plan0.sql | 602 +++++++++++++++++ ..._grain_to_date_metric__plan0_optimized.sql | 24 + ...bdaily_cumulative_window_metric__plan0.sql | 602 +++++++++++++++++ ...ulative_window_metric__plan0_optimized.sql | 24 + ...daily_join_to_time_spine_metric__plan0.sql | 410 ++++++++++++ ..._to_time_spine_metric__plan0_optimized.sql | 25 + ...subdaily_offset_to_grain_metric__plan0.sql | 604 ++++++++++++++++++ ...ffset_to_grain_metric__plan0_optimized.sql | 26 + ...t_subdaily_offset_window_metric__plan0.sql | 604 ++++++++++++++++++ ..._offset_window_metric__plan0_optimized.sql | 26 + ...cumulative_grain_to_date_metric__plan0.sql | 602 +++++++++++++++++ ..._grain_to_date_metric__plan0_optimized.sql | 24 + ...bdaily_cumulative_window_metric__plan0.sql | 602 +++++++++++++++++ ...ulative_window_metric__plan0_optimized.sql | 24 + ...daily_join_to_time_spine_metric__plan0.sql | 410 ++++++++++++ ..._to_time_spine_metric__plan0_optimized.sql | 25 + ...subdaily_offset_to_grain_metric__plan0.sql | 604 ++++++++++++++++++ ...ffset_to_grain_metric__plan0_optimized.sql | 26 + ...t_subdaily_offset_window_metric__plan0.sql | 604 ++++++++++++++++++ ..._offset_window_metric__plan0_optimized.sql | 26 + ...cumulative_grain_to_date_metric__plan0.sql | 602 +++++++++++++++++ ..._grain_to_date_metric__plan0_optimized.sql | 24 + ...bdaily_cumulative_window_metric__plan0.sql | 602 +++++++++++++++++ ...ulative_window_metric__plan0_optimized.sql | 24 + ...daily_join_to_time_spine_metric__plan0.sql | 410 ++++++++++++ ..._to_time_spine_metric__plan0_optimized.sql | 25 + ...subdaily_offset_to_grain_metric__plan0.sql | 604 ++++++++++++++++++ ...ffset_to_grain_metric__plan0_optimized.sql | 26 + ...t_subdaily_offset_window_metric__plan0.sql | 604 ++++++++++++++++++ ..._offset_window_metric__plan0_optimized.sql | 26 + ...cumulative_grain_to_date_metric__plan0.sql | 602 +++++++++++++++++ ..._grain_to_date_metric__plan0_optimized.sql | 24 + ...bdaily_cumulative_window_metric__plan0.sql | 602 +++++++++++++++++ ...ulative_window_metric__plan0_optimized.sql | 24 + ...daily_join_to_time_spine_metric__plan0.sql | 410 ++++++++++++ ..._to_time_spine_metric__plan0_optimized.sql | 25 + ...subdaily_offset_to_grain_metric__plan0.sql | 604 ++++++++++++++++++ ...ffset_to_grain_metric__plan0_optimized.sql | 26 + ...t_subdaily_offset_window_metric__plan0.sql | 604 ++++++++++++++++++ ..._offset_window_metric__plan0_optimized.sql | 26 + 60 files changed, 17682 insertions(+) create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0_optimized.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0.sql create mode 100644 tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0_optimized.sql 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_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/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_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_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_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