From 55857c8f16146e81218468a7af446e81803e114f Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:43:20 +0000 Subject: [PATCH 1/7] clariy multihop depth this pr clarifies multi-hop depth and whether more than 3 joins are supported in mf. stemmed from users asking and this slack thread: https://dbt-labs.slack.com/archives/C03KHQRQUBX/p1708571327378159?thread_ts=1708570486.187929&cid=C03KHQRQUBX --- website/docs/docs/build/join-logic.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/website/docs/docs/build/join-logic.md b/website/docs/docs/build/join-logic.md index e2656692eee..68fd6b3deaa 100644 --- a/website/docs/docs/build/join-logic.md +++ b/website/docs/docs/build/join-logic.md @@ -84,17 +84,15 @@ mf query --metrics average_purchase_price --dimensions metric_time,user_id__type ## Multi-hop joins -:::info -MetricFlow can join three tables at most, supporting multi-hop joins with a limit of two hops. -::: +MetricFlow allows users to join measures and dimensions across a graph of entities, referred to as a 'multi-hop join.' This is because users can move from one table to another like a 'hop' within a graph. -MetricFlow allows users to join measures and dimensions across a graph of entities, which we refer to as a 'multi-hop join.' This is because users can move from one table to another like a 'hop' within a graph. +MetricFlow can join up to three tables, supporting multi-hop joins with a limit of two hops. This enables complex data analysis without ambiguous paths. It supports navigating through data models, like moving from `orders` to `customers` to `country` tables. While direct three-hop paths are limited to prevent confusion from multiple routes to the same data, MetricFlow does allow joining more than three tables if the joins don’t exceed two hops to reach a dimension. -Here's an example schema for reference: +For example, if you have two models, `country` and `region`, where customers are linked to countries, which in turn are linked to regions. You can join all of them in a single SQL query and can dissect `orders` by `customer__country_country_name` but not by `customer__country__region_name`. -![Multi-Hop-Join](/img/docs/building-a-dbt-project/multihop-diagram.png) +![Multi-Hop-Join](/img/docs/building-a-dbt-project/multihop-diagram.png "Example schema for reference") -Notice how this schema can be translated into the three MetricFlow semantic models below to create the metric 'Average purchase price by country' using the `purchase_price` measure from the sales table and the `country_name` dimension from the `country_dim` table. +Notice how the schema can be translated into the following three MetricFlow semantic models to create the metric 'Average purchase price by country' using the `purchase_price` measure from the sales table and the `country_name` dimension from the `country_dim` table. ```yaml semantic_models: From ce6ed63edf3d5e0ea46b60c9ee01f812c4f6f18b Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:46:05 +0000 Subject: [PATCH 2/7] Update join-logic.md --- website/docs/docs/build/join-logic.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/website/docs/docs/build/join-logic.md b/website/docs/docs/build/join-logic.md index 68fd6b3deaa..58f5322e61e 100644 --- a/website/docs/docs/build/join-logic.md +++ b/website/docs/docs/build/join-logic.md @@ -74,7 +74,7 @@ MetricFlow will use `user_id` as the join key to join two semantic models, `tran Note that the `average_purchase_price` measure is defined in the `transactions` semantic model, where `user_id` is a foreign entity. However, the `user_signup` semantic model has `user_id` as a primary entity. -Since this is a foreign-to-primary relationship, a left join is implemented where the `transactions` semantic model joins the `user_signup` semantic model, since the `average_purchase_price` measure is defined in the `transactions` semantic model. +Since this is a foreign-to-primary relationship, a left join is implemented where the `transactions` semantic model joins the `user_signup` semantic model since the `average_purchase_price` measure is defined in the `transactions` semantic model. When querying dimensions from different semantic models using the CLI, a double underscore (or dunder) is added to the dimension name after the joining entity. In the CLI query shown below, `user_id__type` is included as a `dimension`. @@ -86,7 +86,10 @@ mf query --metrics average_purchase_price --dimensions metric_time,user_id__type MetricFlow allows users to join measures and dimensions across a graph of entities, referred to as a 'multi-hop join.' This is because users can move from one table to another like a 'hop' within a graph. -MetricFlow can join up to three tables, supporting multi-hop joins with a limit of two hops. This enables complex data analysis without ambiguous paths. It supports navigating through data models, like moving from `orders` to `customers` to `country` tables. While direct three-hop paths are limited to prevent confusion from multiple routes to the same data, MetricFlow does allow joining more than three tables if the joins don’t exceed two hops to reach a dimension. +MetricFlow can join up to three tables, supporting multi-hop joins with a limit of two hops. This does the following: +- Enables complex data analysis without ambiguous paths. +- Supports navigating through data models, like moving from `orders` to `customers` to `country` tables. +- While direct three-hop paths are limited to prevent confusion from multiple routes to the same data, MetricFlow does allow joining more than three tables if the joins don’t exceed two hops to reach a dimension. For example, if you have two models, `country` and `region`, where customers are linked to countries, which in turn are linked to regions. You can join all of them in a single SQL query and can dissect `orders` by `customer__country_country_name` but not by `customer__country__region_name`. From 8e120fb82158a710043644c153ba5012559eca70 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:04:01 +0000 Subject: [PATCH 3/7] Update join-logic.md add 3rd sm --- website/docs/docs/build/join-logic.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/docs/build/join-logic.md b/website/docs/docs/build/join-logic.md index 58f5322e61e..277b0b9b8b4 100644 --- a/website/docs/docs/build/join-logic.md +++ b/website/docs/docs/build/join-logic.md @@ -125,6 +125,8 @@ semantic_models: - name: signup_date type: time - name: country_dim + + - name: country entities: - name: country_id type: primary From 8322777296cba474a7f0cc56b764500e7206c998 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:04:09 +0000 Subject: [PATCH 4/7] Update website/docs/docs/build/join-logic.md Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> --- website/docs/docs/build/join-logic.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/build/join-logic.md b/website/docs/docs/build/join-logic.md index 277b0b9b8b4..38dfacd4249 100644 --- a/website/docs/docs/build/join-logic.md +++ b/website/docs/docs/build/join-logic.md @@ -84,7 +84,7 @@ mf query --metrics average_purchase_price --dimensions metric_time,user_id__type ## Multi-hop joins -MetricFlow allows users to join measures and dimensions across a graph of entities, referred to as a 'multi-hop join.' This is because users can move from one table to another like a 'hop' within a graph. +MetricFlow allows users to join measures and dimensions across a graph of entities, referred to as a 'multi-hop join' because users can move from one table to another like a 'hop' within a graph. MetricFlow can join up to three tables, supporting multi-hop joins with a limit of two hops. This does the following: - Enables complex data analysis without ambiguous paths. From e2ea91ff4c3a5b26d208a0493e53aea0afe7cffb Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:04:21 +0000 Subject: [PATCH 5/7] Update website/docs/docs/build/join-logic.md Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> --- website/docs/docs/build/join-logic.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/build/join-logic.md b/website/docs/docs/build/join-logic.md index 38dfacd4249..42cff2d5a9c 100644 --- a/website/docs/docs/build/join-logic.md +++ b/website/docs/docs/build/join-logic.md @@ -91,7 +91,7 @@ MetricFlow can join up to three tables, supporting multi-hop joins with a limit - Supports navigating through data models, like moving from `orders` to `customers` to `country` tables. - While direct three-hop paths are limited to prevent confusion from multiple routes to the same data, MetricFlow does allow joining more than three tables if the joins don’t exceed two hops to reach a dimension. -For example, if you have two models, `country` and `region`, where customers are linked to countries, which in turn are linked to regions. You can join all of them in a single SQL query and can dissect `orders` by `customer__country_country_name` but not by `customer__country__region_name`. +For example, if you have two models, `country` and `region`, where customers are linked to countries, which in turn are linked to regions, you can join all of them in a single SQL query and can dissect `orders` by `customer__country_country_name` but not by `customer__country__region_name`. ![Multi-Hop-Join](/img/docs/building-a-dbt-project/multihop-diagram.png "Example schema for reference") From e6b7115e8f10c78c05c68ccf219c54ceff2ae460 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:45:14 +0000 Subject: [PATCH 6/7] Update join-logic.md --- website/docs/docs/build/join-logic.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/docs/docs/build/join-logic.md b/website/docs/docs/build/join-logic.md index 42cff2d5a9c..4d9004c3f7e 100644 --- a/website/docs/docs/build/join-logic.md +++ b/website/docs/docs/build/join-logic.md @@ -89,7 +89,8 @@ MetricFlow allows users to join measures and dimensions across a graph of entiti MetricFlow can join up to three tables, supporting multi-hop joins with a limit of two hops. This does the following: - Enables complex data analysis without ambiguous paths. - Supports navigating through data models, like moving from `orders` to `customers` to `country` tables. -- While direct three-hop paths are limited to prevent confusion from multiple routes to the same data, MetricFlow does allow joining more than three tables if the joins don’t exceed two hops to reach a dimension. + +While direct three-hop paths are limited to prevent confusion from multiple routes to the same data, MetricFlow does allow joining more than three tables if the joins don’t exceed two hops to reach a dimension. For example, if you have two models, `country` and `region`, where customers are linked to countries, which in turn are linked to regions, you can join all of them in a single SQL query and can dissect `orders` by `customer__country_country_name` but not by `customer__country__region_name`. From e7ee93517d889e7fb137835c3b894a94e4fecf27 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:51:39 +0000 Subject: [PATCH 7/7] Update website/docs/docs/build/join-logic.md --- website/docs/docs/build/join-logic.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/build/join-logic.md b/website/docs/docs/build/join-logic.md index 4d9004c3f7e..f83fd063f05 100644 --- a/website/docs/docs/build/join-logic.md +++ b/website/docs/docs/build/join-logic.md @@ -84,7 +84,7 @@ mf query --metrics average_purchase_price --dimensions metric_time,user_id__type ## Multi-hop joins -MetricFlow allows users to join measures and dimensions across a graph of entities, referred to as a 'multi-hop join' because users can move from one table to another like a 'hop' within a graph. +MetricFlow allows users to join measures and dimensions across a graph of entities by moving from one table to another within a graph. This is referred to as "multi-hop join". MetricFlow can join up to three tables, supporting multi-hop joins with a limit of two hops. This does the following: - Enables complex data analysis without ambiguous paths.