Is this a new bug in metricflow?
Current Behavior
When querying metrics in MetricFlow v0.209.0, generated SQL references measure name as a column instead of applying the aggregation function to the expr field. This causes "Unrecognized name" errors in BigQuery.
Example generated SQL (v0.209.0)
SELECT SUM(session_count) AS session_count
FROM `product`.`product_stats__sessions`
This treats session_count as an existing column in the table, which doesn't exist.
Expected Behavior
MetricFlow should apply the aggregation function to the expr field defined in the measure configuration.
Expected SQL (as in v0.208.0)
SELECT SUM(CASE WHEN session_id IS NOT NULL THEN 1 ELSE 0 END) AS session_count
FROM .`product`.`product_stats__sessions`
Steps To Reproduce
- Define a measure in semantic model:
semantic_models:
- name: sessions
model: ref('product_stats__sessions')
measures:
- name: session_count
agg: count
expr: session_id
- Query the metric:
mf query --metrics session_count --explain
- Observe the incorrect SQL generation
Relevant log output
google.api_core.exceptions.BadRequest: 400 Unrecognized name: session_count at [9:7]
Location: EU
Job ID: xxx
dbt_common.exceptions.base.DbtDatabaseError: Database Error
Unrecognized name: session_count at [9:7]
Environment
- OS: Debian 12.12
- Python: 3.12.12
- dbt: 1.10.15
- dbt-metricflow: 0.11.0
- Metricflow: 0.209.0
Which database are you using?
No response
Additional Context
This seems related to the measures to simple metrics migration introduced in PRs #1889, #1892, #1893
Downgrading to MetricFlow 0.208.0 resolves the issue
Is a fix expected in an upcoming release?
Is this a new bug in metricflow?
Current Behavior
When querying metrics in MetricFlow v0.209.0, generated SQL references measure name as a column instead of applying the aggregation function to the
exprfield. This causes "Unrecognized name" errors in BigQuery.Example generated SQL (v0.209.0)
This treats
session_countas an existing column in the table, which doesn't exist.Expected Behavior
MetricFlow should apply the aggregation function to the
exprfield defined in the measure configuration.Expected SQL (as in v0.208.0)
Steps To Reproduce
Relevant log output
Environment
Which database are you using?
No response
Additional Context
This seems related to the measures to simple metrics migration introduced in PRs #1889, #1892, #1893
Downgrading to MetricFlow 0.208.0 resolves the issue
Is a fix expected in an upcoming release?