About Spectre Joins

Spectre supports join operations similar to those available in the Integrator language. The idea of a join is to match rows from a left and right flow and either discard or duplicate records. The join types match those of classical relational database logic. That is, the Spectre join types are as follows:

  • Left Outer: All rows from the left flow are returned.
  • For every row in the left table, Spectre finds the set of rows in the right table with matching values in the key fields. If there is no right match, nulls are used as the values for the columns for which the right table would otherwise supply values. When there is a match, the left row is combined with each of the matching rows on the right.
  • Right Outer: All rows from the right flow are returned.
  • The right join is like a left join, except that the engine is examining the rows of the right table for matches in the left table. That is, for every row in the right table, Spectre finds the set of rows in the left table with matching values in the key fields. If there is no left match, nulls are used as the values for the columns for which the left table would otherwise supply values. When there is a match, the right row is combined with each of the matching rows on the left.
  • Inner Join: Only rows that have matching keys are returned.
  • The inner join is identical to the left outer join, except that when there is no match between the left and right, no row is returned.
  • Outer Join: All rows are returned in the output flow.
  • The outer join follows a similar key matching pattern as the inner join, but every key value in either of the tables is represented. For the columns supplied by the table where the key value is absent, nulls are placed.

To understand how these operations fit together, consider that the following holds for all tables l, r:

left-outer-join(l, r) + right-outer-join(l, r) = outer-join(l, r) + inner-join(l, r)