table::ops
On this page
- Structs
- Traits
JoinSide1Difference1- Implementations
impl Table2
Relational algebra as operators: the join symbols of Codd's algebra
(⋈ ⟕ ⟖ ⟗ ⋉ ▷), the set operators (∪ ∩ from core, ∖ here) and
indexing by column name. The joins bind like *, the set operators
like + / -, so a ⋈ b ∪ c is (a ⋈ b) ∪ c.
Operators cannot throw, so where Table::join would throw these
panic with the same message; call the methods when the column names
come from data.
Structs
KeyedSource
pub struct KeyedA table with the key columns to join it on: b.on(["id"]).
Trait implementations 1
impl JoinSide for Keyed
Traits
JoinSideSource
pub trait JoinSideThe right side of a join operator: a whole table (a natural join on the shared names) or a keyed one.
The table and the key names, given the left table.
RelationalSource
pub trait Relational<Rhs>Joins as operators. With a plain table on the right the keys are
the shared column names (a natural join); b.on(["k"]) names them.
| Operator | Join | Method |
|---|---|---|
a ⋈ b | inner | a.join(b, ks, How::Inner) |
a ⟕ b | left outer | How::Left |
a ⟖ b | right outer | How::Right |
a ⟗ b | full outer | How::Outer |
a ⋉ b | semi | How::Semi |
a ▷ b | anti | How::Anti |
let people = table::table!{ "id": [1, 2, 3], "name": ["ann", "bob", "cy"] };
let orders = table::table!{ "id": [1, 1, 3], "amount": [5.0, 7.0, 2.0] };
assert((people ⋈ orders).nrows() == 3);
assert((people ⟕ orders).nrows() == 4);
assert((people ⋉ orders).nrows() == 2);
assert((people ▷ orders).row(0).str("name") == "bob");
self ⋈ rhs: inner join.self ⟕ rhs: left outer join.self ⟖ rhs: right outer join.self ⟗ rhs: full outer join.self ⋉ rhs: left semi-join, rows ofselfwith a match.self ▷ rhs: anti-join, rows ofselfwith no match.
DifferenceSource
pub trait Difference<Rhs = Self>∖: set difference.
self ∖ rhs.
Implementations
impl Table
This table keyed by
names, the right side of a join operator.nabilet a = table::table!{ "id": [1, 2], "x": [1.0, 2.0] }; let b = table::table!{ "id": [2, 3], "y": ["b", "c"] }; let j = a ⋈ b.on(["id"]); assert(j.nrows() == 1 && j.row(0).str("y") == "b");The names this table shares with
o: the keys of a natural join.