Skip to content

[Bug] Metric defined with create_metric: true on a measure doesn't pick up on the expr #1942

@siljamardla

Description

@siljamardla

Is this a new bug in metricflow?

  • I believe this is a new bug in metricflow
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

This is how I have defined a measure. Notice the expr differs from the name.

      - name: sum_github_commit_file_deletions
        expr: commit_file_deletions
        agg: sum
        create_metric: true
        description: Sum of GitHub commit file deletions

When I explain the metric with a simple command:

mf query --explain --metrics sum_github_commit_file_deletions

I get SQL code that is incorrect. It uses the measure name, not the expression in the aggregation. My table doesn't have a column called sum_github_commit_file_deletions, that's just the measure name.

SELECT
  SUM(sum_github_commit_file_deletions) AS sum_github_commit_file_deletions
FROM `fact_github_commit_file` fact_github_commit_file_src_10000 

Expected Behavior

The expected output is

SELECT
  SUM(commit_file_deletions) AS sum_github_commit_file_deletions
FROM `fact_github_commit_file` fact_github_commit_file_src_10000 

where the expression is used inside the aggregation.

Steps To Reproduce

Try it on any measure that has an expression (which is different from the measure name).

Relevant log output

Environment

Python:         3.12.11
dbt-databricks: 1.10.14
dbt-spark:      1.9.3
dbt-core:       1.10.13
metricflow                0.209.0
dbt-metricflow            0.11.0

Which database are you using?

other (mention it in "Additional Context")

Additional Context

Databricks

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageTasks that need to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions