leftOuterJoin
leftOuterJoin joins data from a pair of tables - a left table and a right table - based upon one or more match columns (columnsToMatch). The match columns establish key identifiers in the source tables that are joined. Any data type can be used as keys (custom objects must implement consistent equality and hashCode).
The resultant table contains all rows from the left table (the first given) as well as rows from the right table that have matching keys in the identifier column(s).
Note
This table operation is currently experimental. The API may change in the future.
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
| leftTable | Table | The left table from which data is joined. |
| rightTable | Table | The right table from which data is joined. |
| columnsToMatch | String | Columns from the left and right tables used to join on.
|
| columnsToMatch | Collection<String> | Columns from the left and right tables used to join on. Each element of the collection is a single match.
|
| columnsToAdd | String | The columns from the right table to add to the left table based on key.
|
| columnsToAdd | Collection<String> | The columns from the right table to add to the left table based on key.
|
| reserveBits | int | The number of bits of each result row key to reserve for the right table rows that match a left table row, between 1 and 62 (inclusive). If omitted, 10 bits are reserved unless configured otherwise. Reserving enough bits for the largest group of matching right table rows avoids shifting result rows as groups grow. If the maximum size of a right table's group is small, reserve fewer bits by setting |
Returns
A new table containing all rows from the left table and matching rows from the right table. A left table row with no matching right table rows is included once, with null values in the columns from the right table. If there are multiple matches between a row from the left table and rows from the right table, all matching combinations will be included. If no match columns are specified, every combination of left and right table rows is included; if the right table is empty, each left table row is included once with null values in the columns from the right table.
Examples
The following example creates two source table and performs a leftOuterJoin on them. It gives no columnsToAdd, so all columns from the right table appear in the result table.
The following example creates two source tables and performs a leftOuterJoin on them. It specifies C as the only columnsToAdd, so C is the only column from the right table that gets added to result.
The example below shows how to join tables on match columns with different names and rename appended columns when performing a leftOuterJoin.