JOINs
Pinot supports JOINs, including left, right, full, semi, anti, lateral, and equi JOINs. Use JOINs to connect two table to generate a unified view, based on a related column between the tables.
Last updated
Was this helpful?
Pinot supports JOINs, including left, right, full, semi, anti, lateral, and equi JOINs. Use JOINs to connect two table to generate a unified view, based on a related column between the tables.
Last updated
Was this helpful?
This page explains the syntax used to write join. In order to get a more in deep knowledge of how joins work it is recommended to read and also from Star Tree.
The inner join selects rows that have matching values in both tables.
Joins a table containing user transactions with a table containing promotions shown to the users, to show the spending for every userID.
A left join returns all values from the left relation and the matched values from the right table, or appends NULL if there is no match. Also referred to as a left outer join.
A right join returns all values from the right relation and the matched values from the left relation, or appends NULL if there is no match. It is also referred to as a right outer join.
A full join returns all values from both relations, appending NULL values on the side that does not have a match. It is also referred to as a full outer join.
Semi-join returns rows from the first table where matches are found in the second table. Returns one copy of each row in the first table for which a match is found.
Some subqueries, like the following are also implemented as a semi-join under the hood:
Anti-join returns rows from the first table where no matches are found in the second table. Returns one copy of each row in the first table for which no match is found.
Some subqueries, like the following are also implemented as an anti-join under the hood:
An equi join uses an equality operator to match a single or multiple column values of the relative tables.
An ASOF JOIN
selects rows from two tables based on a "closest match" algorithm.
The comparison operator in the MATCH_CONDITION
can be one out of - <
, >
, <=
, >=
. Similar to an inner join, an ASOF join first calculate the set of matching rows in the right table for each row in the left table based on the ON
condition. But instead of returning all of these rows, the only one returned is the closest match (if one exists) based on the match condition. Note that the two columns in the MATCH_CONDITION
should be of the same type.
The join condition in ON
is mandatory and has to be a conjunction of equality comparisons (i.e., non-equi join conditions and clauses joined with OR
aren't allowed). ON true
can be used in case the join should only be performed using the MATCH_CONDITION
.
A LEFT ASOF JOIN
is similar to the ASOF JOIN
, with the only difference being that all rows from the left table are returned, even those without a match in the right table with the unmatched rows being padded with NULL
values (similar to the difference between an INNER JOIN
and a LEFT JOIN
).
A cross join returns the Cartesian product of two relations. If no WHERE clause is used along with CROSS JOIN, this produces a result set that is the number of rows in the first table multiplied by the number of rows in the second table. If a WHERE clause is included with CROSS JOIN, it functions like an .