@bijectionhq/library-relations is the typed relation builder. It is the
one query syntax Bijection analyses. Virtual tables, pipeline outputs and
query-language connectors all take a Relation<Row>, and bijection check
compiles it through the semantics guest. The guest derives the relation’s
key, column types, lineage and change class, and renders the statement in
the receiver’s own dialect. You never write a digest, a key proof or a
column list twice.
A source relation handle is already a relation: there is no entry word.
Handles come from warehouse.relation(locator, { … }) in
@bijectionhq/app-sql, from
dataset(name, { fields, key }) in
@bijectionhq/library-pipelines, and from an S3
connector’s relation. Every method returns another Relation.
bijection/relations.ts
Operators
Predicates and values use the guard builder’s words:
equals, notEquals,
lessThan, lessOrEqual, greaterThan, greaterOrEqual, oneOf,
isNull, isNotNull, and, or, not, add, subtract and multiply.
An instant takes an exact span: at.subtract({ days: 30 }). The library also
exports:
at, the clock: the source instant,now − skewon an undated read and the cut on a dated one. It is never part of an effective key.at,fromandtoare reserved bind names. A clock function in SQL text refusesFunctionRefused.arg(name, t.x), a typed bind. A pipeline’sargsgive its value.constant(t.x, value), a typed literal sent as a bind.coalesce(value, …fallbacks)andwhen(condition, value).when(…).otherwise(…).builtin({ dialect, name, returns }), a deterministic built-in of one dialect that its function catalog classifies. A relation that calls one is pinned to that dialect, and lowering for another refusesDialectMissing.
What check derives
- Key. The key is proved from the source keys, never accepted on
assertion. With exactly one minimal key,
keymay be omitted. With several,keymust name one (KeyAmbiguous). A written key is a pin: it must equal the proved key, and an edit that changes the proof refusesKeyUnproved. - Types. The builder’s TypeScript row type must equal the guest’s
inference, or check refuses
TypeMismatch. - Lowering. Each dialect lowers the relation exactly, pinning casts,
null-safe equality and null ordering. A construct a dialect cannot lower
exactly refuses
DialectMissing; there is no lowest common denominator. Retargeting means changing the receiver. - Read set and lineage. The read set is the source handles the relation
reaches. A pipeline step’s change class (
linear,group,bilinear,keyed(…)oropaque) comes from the same derivation.
bijection.statements/ beside
the lock (see bijection.lock).
Native text
For what a relation cannot say, write native text in the receiver’s dialect:receiver.sql({ key, fields })`…` . A pipeline run target also
takes sql(dialect).file(path, { inputs, args, key, fields }); the file
form on a warehouse receiver is not implemented yet. Native text is pinned to
its dialect and never retargeted. Its key and fields are checked on every
answer. See native text for what check
admits.