-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Derived & component metrics in same mf query results in complex/unnecessary joins #422
Comments
Hi, guys! I would like to second @callum-mcdata problem. Here we intend to use metric flow to generate a more generic datasets based on our data warehouse. However, as of right now, we can't use metricflow directly. The problem for us is that it generates a more complicated query just to calculate the ratio and derived metrics on different subqueries, which wouldn't be a complete problem, but it locks the dimensions by which is calculated. For example, if a have I get that the current for facilitates the filter option as well as other features, but it really doesn't work when you want less datasets for your business stakeholder to make sense. Environment (please complete the following information):
Note: The query does indeed work fine, it's just a question of generalization. |
@giuseppecg thanks for adding more context to this issue! I created another issue with a proposed approach to solving the complex SQL rending. Would love your eyes on that.
I wanted to dig into this a bit more because I think it may be a separate issue. Even if we generate less complex SQL for this case, you still won't be able to re-aggregate ratio metrics across different dimensions. This is one of the drawbacks to using static data sets. What's the reason you decided to go with this approach? Is it mainly as an integration path for a BI tool we don't yet support? |
Generation of queries with FULL OUTER JOIN is much less efficient that reusing metrics from Subqueries. This is really an anti pattern. Do we have eyes on this ? |
Apologies on the bad title, not sure how exactly to describe this one?
Describe the bug
I believe that the new
derived
metric type does not recognize thecomponent
metrics included asmetrics
during the query generation. When a user queries both thederived
and thecomponent
metrics, the SQL generated appears to include two different queries that are thenfull outer join
ed, similar to the pattern executed for metrics that don't share the same base table.This assumption of what the issue is is partially derived by a comment by @QMalcolm in #416 where he mentioned
our measures (which is how we treat component metrics)
and then re-enforced when comparing the SQL generated by querying derived+component metrics versus just derived metrics.Here is the SQL produced when querying both the derived & component metrics:
Derived metric + component metrics
MF Command:
mf query --metrics revenue,costs,taxes,net_profit --dimensions metric_time__month,location_name
Here is the SQL produced when just querying the derived metric
Just derived metric
MF Command:
mf query --metrics net_profit --dimensions metric_time__month --order metric_time__month
Steps To Reproduce
Expected behavior
I would suspect that the query generated in the second example would be used but the component metrics being calculated in the subquery would be used.
Environment (please complete the following information):
Note:
The query works just fine but wanted to 🎏 because I was digging into the new implementation of derived metrics to test out the dbt integration
The text was updated successfully, but these errors were encountered: