packages

table::join

On this page

Hash joins. The right table's key codes go into an Index (one group per distinct key, its rows contiguous); each left row is hashed and probed. Text keys of both sides share one dictionary, so the probe compares integers. A null key matches nothing.

Enums

HowSource

pub enum How

Which rows a join keeps.

HowRows
Innerevery matching pair
Leftevery left row, matched or with nulls on the right
Rightevery right row, matched or with nulls on the left
OuterLeft, then the right rows nothing matched
Semileft rows that have a match (left columns only)
Antileft rows that have none (left columns only)

Implementations

impl Table

  • pub fn join(self, o: Table, on: List<str>, how: How) throws (TableError) -> Table§

    Source

    Join with o on the columns on, present in both.

    nabi
    use table::How;
    let a = table::table!{ "id": [1, 2, 3], "x": ["a", "b", "c"] };
    let b = table::table!{ "id": [3, 1, 1], "y": [30.0, 10.0, 11.0] };
    let j = try a.join(b, ["id"], How::Inner) catch _ { a };
    assert(j.names() == ["id", "x", "y"]);
    assert(j.nrows() == 3);
    let l = try a.join(b, ["id"], How::Left) catch _ { a };
    assert(l.nrows() == 4 && l.row(2).f64("y") is none);
    
  • pub fn join_on(self, o: Table, left_on: List<str>, right_on: List<str>, how: How) throws (TableError) -> Table§

    Source

    Join where the key columns have different names: left_on[k] of this table matches right_on[k] of o. The result has this table's columns, then o's other columns; a name both sides use gets _right on o's side. For Outer / Right, a key column holds the key of whichever side has the row.