diff --git a/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/user_sm_source.yaml b/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/user_sm_source.yaml index b0db8c59f1..6e36641f8e 100644 --- a/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/user_sm_source.yaml +++ b/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/user_sm_source.yaml @@ -7,6 +7,9 @@ semantic_model: schema_name: $source_schema alias: dim_users + defaults: + agg_time_dimension: created_at + dimensions: - name: ds type: time @@ -45,3 +48,9 @@ semantic_model: - name: user type: primary expr: user_id + + measures: + - name: new_users + expr: "1" + agg: SUM + create_metric: true \ No newline at end of file diff --git a/tests_metricflow/integration/test_cases/itest_metrics.yaml b/tests_metricflow/integration/test_cases/itest_metrics.yaml index 7c6e96f8f6..fcf6f0934e 100644 --- a/tests_metricflow/integration/test_cases/itest_metrics.yaml +++ b/tests_metricflow/integration/test_cases/itest_metrics.yaml @@ -2227,3 +2227,55 @@ integration_test: FROM {{ source_schema }}.fct_bookings WHERE ({{ render_date_trunc("ds", TimeGranularity.DAY) }} < '2012-12-20') AND ({{ render_date_trunc("ds", TimeGranularity.WEEK) }} > '2019-12-18') +--- +integration_test: + name: simple_metric_with_sub_daily_dimension + description: Tests querying a metric with a sub-daily dimension + model: SIMPLE_MODEL + metrics: ["new_users"] + group_bys: ["user__last_profile_edit_ts__millisecond"] + check_query: | + SELECT + {{ render_date_trunc("last_profile_edit_ts", TimeGranularity.MILLISECOND) }} AS user__last_profile_edit_ts__millisecond + , SUM(1) AS new_users + FROM {{ source_schema }}.dim_users + GROUP BY {{ render_date_trunc("last_profile_edit_ts", TimeGranularity.MILLISECOND) }} +--- +integration_test: + name: simple_metric_with_joined_sub_daily_dimension + description: Tests querying a metric with a sub-daily dimension that requires a join + model: SIMPLE_MODEL + metrics: ["bookings"] + group_bys: ["user__last_login_ts__minute"] + check_query: | + SELECT + subq_8.user__last_login_ts__minute AS listing__user__last_login_ts__minute + , SUM(subq_2.bookings) AS bookings + FROM ( + SELECT + {{ render_date_trunc("ds_partitioned", TimeGranularity.DAY) }} AS ds_partitioned__day + , listing_id AS listing + , 1 AS bookings + FROM {{ source_schema }}.fct_bookings + ) subq_2 + LEFT OUTER JOIN ( + SELECT + {{ render_date_trunc("u.ds_partitioned", TimeGranularity.DAY) }} AS user__ds_partitioned__day + , {{ render_date_trunc("u.last_login_ts", TimeGranularity.MINUTE) }} AS user__last_login_ts__minute + , l.listing_id AS listing + FROM {{ source_schema }}.dim_listings_latest l + LEFT OUTER JOIN + {{ source_schema }}.dim_users u + ON + l.user_id = u.user_id + ) subq_8 + ON + ( + subq_2.listing = subq_8.listing + ) AND ( + subq_2.ds_partitioned__day = subq_8.user__ds_partitioned__day + ) + GROUP BY + subq_8.user__last_login_ts__minute + +# Add simple simple query above this - user metric \ No newline at end of file