Enable "geo-joins" in MetricFlow #1551
siljamardla
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A very typical use case:
Something like this


Business question: what was the metric sum_order_value in each area.
To answer this question we'd have to do a "geo-join", i.e. find which orders belong to which areas and then sum up the order values per each area.
I can imagine two ways to enable this.
Create a mapping table between order and area (each team would need to find a way to do this, using some point-in-polygon geo function that is available to them)

NB: This will be a many-to-many table, best practices say there should be a primary key in the table as well :)
To answer the question, we'd then have to generate SQL that would look something like this:

Currently, MetricFlow is not able to generate SQL like this because it's only possible to do joins between foreign and primary keys, but in this case we'd need a join from order_id in the orders table (primary key) to order_id in the mapping table (dimension).
Instead of requiring there to be a mapping table, enable geo-joins in MetricFlow. The answer to the question would look something like this pseudo-code:
Beta Was this translation helpful? Give feedback.
All reactions