Join self with other using the given join expression. Args: other: the right side of the join, ``Table`` or ``JoinResult``. on: a list of column expressions. Each must have == as the top level operation and be of the form LHS: ColumnReference == RHS
(
self,
other: Joinable,
*on: expr.ColumnExpression,
id: expr.ColumnReference | None = None,
how: JoinMode = JoinMode.INNER,
left_instance: expr.ColumnReference | None = None,
right_instance: expr.ColumnReference | None = None,
left_exactly_once: bool = False,
right_exactly_once: bool = False,
)
| 133 | @desugar(substitution={thisclass.left: "self", thisclass.right: "other"}) |
| 134 | @arg_handler(handler=join_kwargs_handler(allow_how=True, allow_id=True)) |
| 135 | def join( |
| 136 | self, |
| 137 | other: Joinable, |
| 138 | *on: expr.ColumnExpression, |
| 139 | id: expr.ColumnReference | None = None, |
| 140 | how: JoinMode = JoinMode.INNER, |
| 141 | left_instance: expr.ColumnReference | None = None, |
| 142 | right_instance: expr.ColumnReference | None = None, |
| 143 | left_exactly_once: bool = False, |
| 144 | right_exactly_once: bool = False, |
| 145 | ) -> JoinResult: |
| 146 | """Join self with other using the given join expression. |
| 147 | |
| 148 | Args: |
| 149 | other: the right side of the join, ``Table`` or ``JoinResult``. |
| 150 | on: a list of column expressions. Each must have == as the top level operation |
| 151 | and be of the form LHS: ColumnReference == RHS: ColumnReference. |
| 152 | id: optional argument for id of result, can be only self.id or other.id |
| 153 | how: by default, inner join is performed. Possible values are JoinMode.{INNER,LEFT,RIGHT,OUTER} |
| 154 | correspond to inner, left, right and outer join respectively. |
| 155 | left_instance/right_instance: optional arguments describing partitioning of the data into |
| 156 | separate instances |
| 157 | left_exactly_once: if you can guarantee that each row on the left side of the join will be |
| 158 | joined at most once, then you can set this parameter to ``True``. Then each row after |
| 159 | getting a match is removed from the join state. As a result, less memory is needed. |
| 160 | Works only for append-only tables. |
| 161 | right_exactly_once: if you can guarantee that each row on the right side of the join will be |
| 162 | joined at most once, then you can set this parameter to ``True``. Then each row after |
| 163 | getting a match is removed from the join state. As a result, less memory is needed. |
| 164 | Works only for append-only tables. |
| 165 | |
| 166 | Returns: |
| 167 | JoinResult: an object on which `.select()` may be called to extract relevant |
| 168 | columns from the result of the join. |
| 169 | |
| 170 | Example: |
| 171 | |
| 172 | >>> import pathway as pw |
| 173 | >>> t1 = pw.debug.table_from_markdown(''' |
| 174 | ... age | owner | pet |
| 175 | ... 10 | Alice | 1 |
| 176 | ... 9 | Bob | 1 |
| 177 | ... 8 | Alice | 2 |
| 178 | ... ''') |
| 179 | >>> t2 = pw.debug.table_from_markdown(''' |
| 180 | ... age | owner | pet | size |
| 181 | ... 10 | Alice | 3 | M |
| 182 | ... 9 | Bob | 1 | L |
| 183 | ... 8 | Tom | 1 | XL |
| 184 | ... ''') |
| 185 | >>> t3 = t1.join( |
| 186 | ... t2, t1.pet == t2.pet, t1.owner == t2.owner, how=pw.JoinMode.INNER |
| 187 | ... ).select(age=t1.age, owner_name=t2.owner, size=t2.size) |
| 188 | >>> pw.debug.compute_and_print(t3, include_id = False) |
| 189 | age | owner_name | size |
| 190 | 9 | Bob | L |
| 191 | """ |
| 192 | return JoinResult._table_join( |