You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the output SQL will have the necessary joins and the WHERE clause becomes valid.
Expected Behavior
MetricFlow should be able to recognise dimensions in --where clauses and add the necessary joins.
At the moment the WHERE clause can be arbitrary and compiled of multiple conditions, even complex things with brackets and whatnot. I agree that this solution allows for the most flexibility and the option should remain. However, there should also be a more controlled way of adding where clauses that relies on the semantics that we have defined and makes sure the outcome is valid SQL.
Steps To Reproduce
I have not tested if the issue only happens due to this particular dimension needing two joins (to dim_city and to dim_country). I suspect not, because the output SQL did not even have a join to dim_city either.
To reproduce, it should be enough to try a --where clause with a dimension and without a --group-by for the same dimension.
Relevant log output
No response
Environment
- OS:
- Python:
- dbt: 1.8
- metricflow:
Which database are you using?
other (mention it in "Additional Context")
Additional Context
spark/databricks
The text was updated successfully, but these errors were encountered:
siljamardla
changed the title
[Bug] Adding a (multi-hop?) dimension in --where but not in --group-by of an MF query will output dysfunctional SQL
[Bug] Adding a dimension in --where but not in --group-by of an MF query will output dysfunctional SQL
Sep 5, 2024
Is this a new bug in metricflow?
Current Behavior
Here's a query to get
my_metric
value, grouped by user name and filtered for country (a valid dimension):This produces SQL that has the following WHERE clause
but it does not have a join to the dimension table
dim_city
(nor todim_country
, which is also needed). Therefore, the SQL cannot be run.There is a workaround: by adding the same dimension in the
--group-by
like this:the output SQL will have the necessary joins and the
WHERE
clause becomes valid.Expected Behavior
MetricFlow should be able to recognise dimensions in
--where
clauses and add the necessary joins.At the moment the WHERE clause can be arbitrary and compiled of multiple conditions, even complex things with brackets and whatnot. I agree that this solution allows for the most flexibility and the option should remain. However, there should also be a more controlled way of adding where clauses that relies on the semantics that we have defined and makes sure the outcome is valid SQL.
Steps To Reproduce
I have not tested if the issue only happens due to this particular dimension needing two joins (to
dim_city
and todim_country
). I suspect not, because the output SQL did not even have a join todim_city
either.To reproduce, it should be enough to try a
--where
clause with a dimension and without a--group-by
for the same dimension.Relevant log output
No response
Environment
Which database are you using?
other (mention it in "Additional Context")
Additional Context
spark/databricks
The text was updated successfully, but these errors were encountered: