Skip to content

mf query ignores earlier --where flags and only applies the last filter #1970

@Keerthi-Kamarthi

Description

@Keerthi-Kamarthi

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

When running mf query with multiple --where flags, only the final --where is applied in the generated SQL. Earlier filters are silently dropped. For example, only ad__ad_status = 'active' appears, while the preceding ad__ad_type = 'googleads' filter is missing.

Expected Behavior

Generated SQL includes both filters in the WHERE clause, effectively:

... WHERE ad__ad_type = 'googleads' AND ad__ad_status = 'active'

Steps To Reproduce

  1. Run:
    mf query --metrics ad_cost
    --group-by ad__platform
    --where "{{ Dimension('ad__ad_type') }} = 'googleads'"
    --where "{{ Dimension('ad__ad_status') }} = 'active'"
    --explain
  2. Inspect the generated SQL.
  3. Observe that only the second filter is present in the WHERE clause.

Relevant log output

SELECT
  ad__ad_id
  , SUM(ad_cost) AS ad_cost
FROM (
  SELECT
    ad_src_10000.ad_id AS ad__ad_id
    , ad_stats_src_10000.cost AS ad_cost
  FROM `pmg-datawarehouse-staging`.`test_core`.`fact_ad` ad_stats_src_10000
  LEFT OUTER JOIN
    `pmg-datawarehouse-staging`.`test_core`.`dim_ad` ad_src_10000
  ON
    ad_stats_src_10000.ad_join_key = ad_src_10000.alli_id
) subq_4
WHERE ad__ad_status = 'active'
GROUP BY
  ad__ad_id

Environment

- OS: macOS 15.7.3 (Build 24G419)
- Python: 3.10.5
- dbt: 1.10.9
- metricflow: 0.11.0

Which database are you using?

No response

Additional Context

Image

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