diff --git a/metricflow/query/query_parser.py b/metricflow/query/query_parser.py index 95607e63ea..7fe1fc7eae 100644 --- a/metricflow/query/query_parser.py +++ b/metricflow/query/query_parser.py @@ -816,6 +816,8 @@ def _get_invalid_linkable_specs( # Because the metric time dimension is a virtual dimension that's not in the model, it won't be included # in valid_linkable_specs. and time_dimension_spec.reference != DataSet.metric_time_dimension_reference() + # TODO: remove line below & add date_part specs to validation paths. + and not time_dimension_spec.date_part ): invalid_linkable_specs.append(time_dimension_spec) diff --git a/metricflow/test/integration/test_cases/itest_metrics.yaml b/metricflow/test/integration/test_cases/itest_metrics.yaml index d88ed9d83c..6e1205f1c4 100644 --- a/metricflow/test/integration/test_cases/itest_metrics.yaml +++ b/metricflow/test/integration/test_cases/itest_metrics.yaml @@ -1057,6 +1057,19 @@ integration_test: FROM {{ source_schema }}.fct_bookings GROUP BY {{ render_extract("ds", DatePart.YEAR) }}; --- +integration_test: + name: simple_query_with_date_part_not_metric_time + description: Test query using date_part + model: SIMPLE_MODEL + metrics: ["bookings"] + group_by_objs: [{"name": "booking__ds", "date_part": "year"}] + check_query: | + SELECT + SUM(1) AS bookings + , {{ render_extract("ds", DatePart.YEAR) }} AS booking__ds__extract_year + FROM {{ source_schema }}.fct_bookings + GROUP BY {{ render_extract("ds", DatePart.YEAR) }}; +--- integration_test: name: simple_query_with_multiple_date_parts description: Test query using multiple date_parts