# Joins

Components to join two or more streams of data.

## Cross Join

**Description**

Performs a Cartesian product (cross join) between two tables, combining every row from the main table with every row from the secondary table. Columns from the secondary table are suffixed with '\_joined' to avoid naming conflicts. Warning: Output size is main\_rows × secondary\_rows, so use with caution on large tables.

**Inputs**

* `Main table [Table]`
* `Secondary table [Table]`

**Outputs**

* `Result table [Table]`

**External links**

[BigQuery reference](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#cross_join)

## Join

**Description**

This component combines rows from two separate tables based on a related column between them.

**Inputs**

* `Main table [Table]`
* `Secondary table [Table]`
* `Column on main table [Column]`
* `Column on secondary table [Column]`
* `Join type [Selection]`

**Outputs**

* `Result table [Table]`

**External links**

[BigQuery reference](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#join_types)

## Join (extended) <a href="#join-extended" id="join-extended"></a>

**Description**

This component combines two input tables based on common fields between the two tables. You can also Join two tables based on record position.

**Inputs**

* `Left table [Table]`
* `Right table [Table]`
* `Join By [Selection]`
* `Column in Left Table [Column]`
* `Column in Right Table [Column]`

**Outputs**

* `Table with unjoined rows from left table [Table]`
* `Table with unjoined rows from right table [Table]`
* `Joined table [Table]`

## Spatial Join

**Description**

This component performs a spatial join between two tables, based on a spatial predicate.

**Inputs**

* `Main table [Table]`
* `Secondary table [Table]`
* `Geo column on main table [Column]`
* `Geo column on secondary table [Column]`
* `Spatial predicate [Selection]`

**Outputs**

* `Result table [Table]`

## Spatial Match

**Description**

This component establishes the spatial relationship (contains, intersects, touches, etc.) between two sets of spatial objects. The component accepts a set of spatial objects from the Target Input and a set of spatial objects from the Universe Input. At least one input stream should contain Polygon type spatial objects.

**Inputs**

* `Targets [Table]`
* `Universe [Table]`
* `Target Spatial Object Field [Column]`
* `Universe Spatial Object Field [Column]`
* `Type of Spatial Match [Selection]`
* `Output Intersection Object (Intersects Only) [Boolean]`

**Outputs**

* `Result table [Table]`

## ST Difference

**Description**

This component creates a new table containing the difference between the geographies of the input table and the combined boundary of the geographies in another table. That is, the part of the original geography that doesn't fall within the boundary of the ancillary table.

Geographies in the secondary table must be of type polygon.

**Inputs**

* `Source table [Table]`
* `Polygons table [Table]`
* `Geo column in source table [Column]`
* `Geo column in polygons table [Column]`

**Outputs**

* `Result table [Table]`

**External links**

[BigQuery reference](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_difference)

## ST Intersection

**Description**

This component creates a new table containing the intersection between the geographies of the input table and the geographies in another table.

Columns from both tables are copied to the output one, and a new one with the intersection is added.

**Inputs**

* `Source table [Table]`
* `Polygons table [Table]`
* `Geo column in source table [Column]`
* `Geo column in secondary table [Column]`

**Outputs**

* `Result table [Table]`

**External links**

[BigQuery reference](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_intersection)

## Union All

**Description**

This component generates a new table that is the union of several input ones.

The input tables must have the same schema.

**Inputs**

* `Tables [Table]`

**Outputs**

* `Result table [Table]`

**External links**

[BigQuery reference](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#union_example)
