INNER JOIN- matching rows between two tables[LEFT] SEMI JOIN- rows in the left-hand table that have matching rows in the right-hand tableLEFT [OUTER] JOIN- matching rows between two tables, and rows in the left-hand table that have no matching rows in the right-hand tableRIGHT [OUTER] JOIN- matching rows between two tables, and rows in the right-hand table that have no matching rows in the left-hand tableFULL [OUTER] JOINmatching rows between two tables, and rows in both tables that have no matching rows in the otherCROSS JOIN- every row in one table paired with every row in the other
- Local - highly performant, but native join criteria must be met
- Distributed - highly flexible, as native join restrictions are lifted, but less performant due to interprocessor communication overhead and requires more memory & disk space to process
Kinetica supports both
JOIN ... ON and WHERE clause syntax for
inner joins; all outer join types (LEFT, RIGHT, & FULL OUTER)
require JOIN ... ON syntax.
For example, to list the name of each employee and the name of the employee’s
manager, using the WHERE clause to specify the join condition:
JOIN via WHERE Clause Example
JOIN ... ON syntax to specify the
join condition:
JOIN via FROM Clause Example
ASOF
Kinetica supports the notion of an inexact match join via theASOF
join function. This feature allows each left-side table record to be matched
to a single right-side table record whose join column value is the smallest or
largest value within a range relative to the left-side join column value. In
the case where multiple right-side table records have the same smallest or
largest value for a given left-side table record, only one of the right-side
table records will be chosen (non-deterministically) and returned as part of the
join.
ASOF Syntax
left_column- name of the column to join on from the left-side tableright_column- name of the column to join on from the right-side tablerel_range_begin- constant value defining the position, relative to each left-side column value, of the beginning of the range in which to match right-side column values; use a negative constant to begin the range before the left-side column value, or a positive one to begin after itrel_range_end- constant value defining the position, relative to each left-side column value, of the end of the range in which to match right-side column values; use a negative constant to end the range before the left-side column value, or a positive one to end after itMIN|MAX- useMINto return the right-side matched record with the smallest join column value; useMAXto return the right-side matched record with the greatest join column value
>=<left-side column value>+ rel_range_begin<=<left-side column value>+ rel_range_end
ASOF joins are unsupported on some materialized views.
In these situations, the materialized view can be recreated with the
KI_HINT_PROJECT_MATERIALIZED_VIEW hint to allow it to be used in an
ASOF join.Examples
The followingASOF call might be used to list, for each flight arrival time,
the soonest flight departure time that occurs between half an hour and an hour
and a half after the arrival; effectively, the time-matching portion of a
connecting flight query:
ASOF Time-Based Expression Example
ASOF call returns right-side locations that are nearest eastward to
each left-side location, for locations within 5 degrees of the left-side:
ASOF Distance-Based Expression Example
ASOF JOIN Example
ASOF join function can only be used as part of a join, it can
effectively be made into a filter condition by sub-selecting the filter criteria
in the FROM clause and joining on that criteria.
For instance, to look up the stock price for a given company as of a given date:
ASOF JOIN with Filter Example