From d1ba6b7d0deb825fca6c29a54b1ef3c93333d9e9 Mon Sep 17 00:00:00 2001 From: stayseesong Date: Mon, 14 Apr 2025 13:48:07 -0700 Subject: [PATCH 1/3] info note on junction table joins --- src/unify/data-graph/index.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/unify/data-graph/index.md b/src/unify/data-graph/index.md index 2061cb55e7..0e0d85485f 100644 --- a/src/unify/data-graph/index.md +++ b/src/unify/data-graph/index.md @@ -354,8 +354,12 @@ For many:many relationships, define the join on between the two entity tables wi **Junction table spec** -| Parameters | Definition | -| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +> info "" +> When used in junctions tables, `left join` is the column on the junction table to link with the parent (left) entity and `right join` is the column on the junction table to join with the child (right) entity. These values don’t actually manipulate the type of join - they are currently always `INNER JOINS`. + + +| Parameters |Definition | +| --------------- | --------------------------------- | | `table_ref` | Defines the fully qualified table reference to the join table: `[database name].[schema name].[table name]`. Segment flexibly supports tables, views and materialized views | | `primary_key` | The unique identifier for the given table. Must be a column with unique values per row | | `left_join_on` | Define the relationship between the left entity table and the junction table: `[left entity slug].[column name] = [junction table column name]`. Note that schema and table are implied within the junction table column name, so you do not need to define it again | From ab276695ef0dcbe29628fb9a7684ece3c98534ef Mon Sep 17 00:00:00 2001 From: stayseesong Date: Tue, 15 Apr 2025 17:03:17 -0700 Subject: [PATCH 2/3] edits --- src/unify/data-graph/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unify/data-graph/index.md b/src/unify/data-graph/index.md index 0e0d85485f..33f78e6559 100644 --- a/src/unify/data-graph/index.md +++ b/src/unify/data-graph/index.md @@ -355,7 +355,7 @@ For many:many relationships, define the join on between the two entity tables wi **Junction table spec** > info "" -> When used in junctions tables, `left join` is the column on the junction table to link with the parent (left) entity and `right join` is the column on the junction table to join with the child (right) entity. These values don’t actually manipulate the type of join - they are currently always `INNER JOINS`. +> When used in junctions tables, `left join` is the column on the junction table to link with the parent (left) entity, and `right join` is the column on the junction table to join with the child (right) entity. These values don’t manipulate the type of join - they are always `INNER JOINS`. | Parameters |Definition | From f7772bef2b5ca87d5aa9a29126e281362b67b5c4 Mon Sep 17 00:00:00 2001 From: stayseesong Date: Wed, 16 Apr 2025 10:54:48 -0700 Subject: [PATCH 3/3] re-write --- src/unify/data-graph/index.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/unify/data-graph/index.md b/src/unify/data-graph/index.md index 33f78e6559..2850531b10 100644 --- a/src/unify/data-graph/index.md +++ b/src/unify/data-graph/index.md @@ -354,10 +354,6 @@ For many:many relationships, define the join on between the two entity tables wi **Junction table spec** -> info "" -> When used in junctions tables, `left join` is the column on the junction table to link with the parent (left) entity, and `right join` is the column on the junction table to join with the child (right) entity. These values don’t manipulate the type of join - they are always `INNER JOINS`. - - | Parameters |Definition | | --------------- | --------------------------------- | | `table_ref` | Defines the fully qualified table reference to the join table: `[database name].[schema name].[table name]`. Segment flexibly supports tables, views and materialized views | @@ -365,6 +361,18 @@ For many:many relationships, define the join on between the two entity tables wi | `left_join_on` | Define the relationship between the left entity table and the junction table: `[left entity slug].[column name] = [junction table column name]`. Note that schema and table are implied within the junction table column name, so you do not need to define it again | | `right_join_on` | Define the relationship between the junction table and the right entity table: `[junction table column name] = [right entity slug].[column name]`. Note that schema and table are implied within the junction table column name, so you do not need to define it again | + +When you define a many-to-many relationship using a junction table, `left_join_on` and `right_join_on` tell Data Graph how to connect each entity to the junction table: + +* Use `left_join_on` to specify which column in the junction table links to the parent (left) entity. + +* Use `right_join_on` to specify which column links to the child (right) entity. + +These fields define the join conditions, but they don’t control how the join is executed. Data Graph always performs inner joins, even if you specify a `left_join_on`. + +If you need behavior similar to a left join (like including unmatched rows), create a view in your warehouse with the logic you’re targeting and reference that view as an entity in your graph. + + **Example:** ```python