Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions .zed/rules
Original file line number Diff line number Diff line change
Expand Up @@ -1490,17 +1490,43 @@ data. The rules:
- Join requires non-overlapping data columns; raises InputValidationError on collision.
- `Rejoin` (provisional, developer, November 21, 2026, ITL-1336) is the operator a diamond
(one stream split into branches, then put back together) is expected to use; `Join` is
unchanged and still extends every input's system-tag names. Rejoin matches EVERY system-tag
column and keeps those columns unchanged (a result row has its origin row's provenance):
every input that states its system-tag columns states the same ones (a branch through
`Join`, `GroupBy` or `Batch` is refused); an input that states none is checked on its table
when computed. At most one row per origin row in each input (a first rule, refused naming the
input and the values); a null system-tag value is refused; a shared user tag, and every
system tag Polars matched, must agree on matched rows bit for bit (so the result never
follows argument order); the inputs' rows must share one data context, read from the
rows, which the result keeps (rows of another are refused; some operators return rows
in the default context, ITL-1339); data columns disjoint; N-ary and commutative; identity
`"Rejoin"`; async is the barrier, which rebuilds each input in its rows' data context.
unchanged and still extends every input's system-tag names. Rejoin keeps the system-tag
columns unchanged (a result row has its origin row's provenance): every input that states
its system-tag columns states the same ones (a branch through `Join`, `GroupBy` or `Batch`
is refused); an input that states none is checked on its table when computed. It is an
inner join on EVERY column its inputs share (developer, November 22, 2026, ITL-1355): the
system tags, a shared user tag, a shared data-tag's source info and the data context,
with `Join`'s equality (NaN equals NaN, `-0.0` equals `0.0`); a null system tag matches
nothing, a null in any other shared column equals a null (on purpose unlike `Join`,
where a null tag key matches nothing). Rejoin never refuses on what
rows hold, only on what the inputs' columns show (system-tag names, a shared column's
Arrow type, disjoint data columns): a row that matches nothing is left out, and rows of
one origin row that differ in another shared column raise `RejoinDifferingColumnWarning`
once per operator and set of columns. The warning is computed from the inputs' own rows
(`_differing_columns`: per shared column, the inputs that have it stacked and counted per
origin row), never from the rows rejoined so far, which have lost the origin rows an
earlier input lacks or disagrees on. System tags are assumed unique (no input is refused
for repeating one); the warning compares repeats by occurrence, and a surplus repeat is
never compared, so it warns for none (developer, November 22, 2026: no code for it). With
repeats and three or more inputs the fold is pairwise in the canonical order and a surplus
repeat left out at one step is not considered again, so which repeats remain can follow
that order (documented; no order-free N-ary rule for repeats without a design). A
shared column keeps the values of the first input that has it, in
the canonical input order (by pipeline hash; equal hashes stay in argument order, which
only the bits of equal floats can follow). With unique system tags the rows are matched
on the system tags first, by the same join as before ITL-1355, and the pairs filtered,
so inputs whose shared columns agree give the same rows in the same order (Polars' join
order depends on the inputs' sizes: never replace that join). When an input repeats an
origin row, rows are paired one to one by occurrence number (`_pairs_of_repeated_origins`:
the k-th with the k-th among rows equal in every shared column, in row order, arrival
order on the async path), in linear time: never join repeats on the system tags alone,
which builds their cross product. The result's data
context is read from its rows (some operators return rows in the default context,
ITL-1339); a result whose table holds rows of several data contexts keeps each in the
data context column, while the rows it yields one by one report the stream's one
context, as for any `ArrowTableStream` (`iter_data`'s limit, not Rejoin's: ITL-1359); N-ary and
commutative; identity `"Rejoin"`; async is the barrier, which rebuilds each input in its
rows' data context.
- `Join` and `SemiJoin` give Polars only their key columns and row numbers (ITL-1284): Polars
decides which rows match, and every output column is taken from the input tables by row
number (`take`), so every value is the input's, bit for bit (they used to carry every column
Expand Down
48 changes: 37 additions & 11 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1534,17 +1534,43 @@ data. The rules:
- Join requires non-overlapping data columns; raises `InputValidationError` on collision.
- `Rejoin` (provisional, developer, November 21, 2026, ITL-1336) is the operator a diamond
(one stream split into branches, then put back together) is expected to use; `Join` is
unchanged and still extends every input's system-tag names. Rejoin matches EVERY system-tag
column and keeps those columns unchanged (a result row has its origin row's provenance):
every input that states its system-tag columns states the same ones (a branch through
`Join`, `GroupBy` or `Batch` is refused); an input that states none is checked on its table
when computed. At most one row per origin row in each input (a first rule, refused naming the
input and the values); a null system-tag value is refused; a shared user tag, and every
system tag Polars matched, must agree on matched rows bit for bit (so the result never
follows argument order); the inputs' rows must share one data context, read from the
rows, which the result keeps (rows of another are refused; some operators return rows
in the default context, ITL-1339); data columns disjoint; N-ary and commutative; identity
`"Rejoin"`; async is the barrier, which rebuilds each input in its rows' data context.
unchanged and still extends every input's system-tag names. Rejoin keeps the system-tag
columns unchanged (a result row has its origin row's provenance): every input that states
its system-tag columns states the same ones (a branch through `Join`, `GroupBy` or `Batch`
is refused); an input that states none is checked on its table when computed. It is an
inner join on EVERY column its inputs share (developer, November 22, 2026, ITL-1355): the
system tags, a shared user tag, a shared data-tag's source info and the data context,
with `Join`'s equality (NaN equals NaN, `-0.0` equals `0.0`); a null system tag matches
nothing, a null in any other shared column equals a null (on purpose unlike `Join`,
where a null tag key matches nothing). Rejoin never refuses on what
rows hold, only on what the inputs' columns show (system-tag names, a shared column's
Arrow type, disjoint data columns): a row that matches nothing is left out, and rows of
one origin row that differ in another shared column raise `RejoinDifferingColumnWarning`
once per operator and set of columns. The warning is computed from the inputs' own rows
(`_differing_columns`: per shared column, the inputs that have it stacked and counted per
origin row), never from the rows rejoined so far, which have lost the origin rows an
earlier input lacks or disagrees on. System tags are assumed unique (no input is refused
for repeating one); the warning compares repeats by occurrence, and a surplus repeat is
never compared, so it warns for none (developer, November 22, 2026: no code for it). With
repeats and three or more inputs the fold is pairwise in the canonical order and a surplus
repeat left out at one step is not considered again, so which repeats remain can follow
that order (documented; no order-free N-ary rule for repeats without a design). A
shared column keeps the values of the first input that has it, in
the canonical input order (by pipeline hash; equal hashes stay in argument order, which
only the bits of equal floats can follow). With unique system tags the rows are matched
on the system tags first, by the same join as before ITL-1355, and the pairs filtered,
so inputs whose shared columns agree give the same rows in the same order (Polars' join
order depends on the inputs' sizes: never replace that join). When an input repeats an
origin row, rows are paired one to one by occurrence number (`_pairs_of_repeated_origins`:
the k-th with the k-th among rows equal in every shared column, in row order, arrival
order on the async path), in linear time: never join repeats on the system tags alone,
which builds their cross product. The result's data
context is read from its rows (some operators return rows in the default context,
ITL-1339); a result whose table holds rows of several data contexts keeps each in the
data context column, while the rows it yields one by one report the stream's one
context, as for any `ArrowTableStream` (`iter_data`'s limit, not Rejoin's: ITL-1359); N-ary and
commutative; identity `"Rejoin"`; async is the barrier, which rebuilds each input in its
rows' data context.
- `Join` and `SemiJoin` give Polars only their key columns and row numbers (ITL-1284): Polars
decides which rows match, and every output column is taken from the input tables by row
number (`take`), so every value is the input's, bit for bit (they used to carry every column
Expand Down
27 changes: 27 additions & 0 deletions changelog.d/ITL-1355.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Changed

- **`Rejoin` matches rows on every column its inputs share and no longer refuses on what
rows hold** (ITL-1355). It is an inner join on the system-tag columns, a tag several
inputs have, the source info of a shared data-tag and the data context, compared as
`Join` compares its keys (NaN equals NaN, `-0.0` equals `0.0`; a null system tag matches
nothing, a null in any other shared column equals a null). A row that matches nothing is
left out. Behaviour change: inputs that `Rejoin` refused with `InputValidationError` now
give fewer rows instead:
- a shared tag, or a shared data-tag's source info, that differs on rows of one origin
row: those rows are left out, and a new `RejoinDifferingColumnWarning` (from
`orcapod.errors`) names the columns, once per operator and set of columns;
- rows of different data contexts: they match nothing (the same warning names the data
context), and each result row keeps its own data context;
- a null in a system-tag column: the row matches nothing;
- equal values in different bits (`-0.0` and `0.0`, NaNs of different payloads): they
match, and the shared column keeps the values of the first input that has it, in
Rejoin's canonical input order (by pipeline hash; inputs with equal pipeline hashes
stay in argument order);
- an input holding two rows of one origin row: no longer refused. System tags are
assumed unique, as every source makes them; repeated ones pair in row order, each row
at most once, in time linear in the rows.

`Rejoin` still refuses what the inputs' columns show: system-tag columns that differ or
are absent, a shared column whose Arrow type differs, overlapping data columns. For every
input it accepted before, the result is unchanged: the same rows in the same order, the
same values, types and hashes.
80 changes: 63 additions & 17 deletions docs/concepts/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,24 +208,49 @@ The rules:
input whose schema states none (a raw stream without system tags, or a node of a loaded
job downstream of a function node, whose saved schema holds none) is checked when the
rejoin is computed, on its rows, by the same rule.
- **One row per origin row.** Rows are matched on every system-tag column. A first rule,
deliberate and open to relaxing later: each input holds at most one row of an origin row,
so pairing is one to one; an input with two rows of one origin row is refused, naming the
input and the system-tag values. No operator that keeps system tags duplicates rows today.
- **Shared tags agree, bit for bit.** A user tag present in several inputs must hold the
same value on matched rows, bit for bit (`-0.0` is not `0.0`, NaNs of different payloads
differ), so the result never depends on the order of the inputs; otherwise Rejoin refuses,
naming the tag. A tag of one input only is kept.
- **Provenance is never null, and exact.** An input with a null in a system-tag column is
refused, naming the column. Matched system-tag values are compared bit for bit too, like
shared tags.
- **One data context.** The inputs' rows must be of one data context; the result keeps
it, and rows of different data contexts are refused. Only the default data context
ships, so this matters only for a stream built in another one. A known limitation
- **An inner join on every shared column.** Rows are put together when they are equal in
every column the inputs share: every system-tag column (so they come from one origin
row), a user tag several inputs have, the source info of a data-tag several inputs have,
and the data context. A row that matches nothing is left out. Rejoin refuses nothing for
what the rows hold: its only refusals are read from the inputs' columns (their system-tag
columns, a shared column's Arrow type, overlapping data columns).
- **Join's equality.** Values are compared as `Join` compares its keys: NaN equals NaN and
`-0.0` equals `0.0`. A null system tag matches nothing, because provenance is never null.
In any other shared column a null equals a null: two rows of one origin row that both hold
no value agree. That differs from `Join` on purpose, where a null tag key matches nothing.
- **A changed shared column is a non-match.** When two branches hold different values in a
shared column on rows of one origin row (two branches each add a tag `run` with different
values, or change a tag's value), those rows are left out, and Rejoin names the columns in
a `RejoinDifferingColumnWarning` (from `orcapod.errors`), once per operator and set of
columns. Every column in which two inputs differ on an origin row is named, whatever the
order of the inputs. To keep the rows, drop or rename the column in one branch before the
rejoin (`drop_tag_columns`, `map_tags`).
- **Unique system tags.** System tags are assumed unique in each input, as every source
makes them, so each row matches at most once; no input is refused for repeating one. Should
an input repeat an origin row, each row still matches at most once: among the rows equal
in every shared column, the first of one input pairs with the first of the other, the
second with the second, in row order (on the async path, the order the rows arrived in).
The warning is narrower for such rows: it compares the repeats of an origin row by
occurrence (the first of one input with the first of another), and a surplus repeat, one
more than another input holds, matches nothing whatever its values and is never compared,
so no warning names a column for it. With three or more inputs, the inputs are paired one
after another in their canonical order, and a surplus repeat left out at one step is not
considered again at a later one, so which repeats remain can depend on that order.
- **The first input's values.** A shared column is kept once, with the values of the first
input that has it. Rejoin takes its inputs in a canonical order, by pipeline hash, so the
result does not follow the order of the arguments; inputs with equal pipeline hashes (two
branches of the same structure) stay in argument order. With unique system tags only the
bits of values that are equal but not identical (`-0.0` and `0.0`, NaNs of different
payloads) can follow it: no row, hash or identity does. A tag of one input only is kept.
- **Data contexts.** The data context is one of the shared columns: rows of different data
contexts match nothing. Each result row keeps its own in the data context column of the
result's table. A stream reports one data context, and so do the rows it yields one by
one (`iter_data`), as for any stream whose table holds rows of several (ITL-1359). Only the default
data context ships, so this matters only for a stream built in another one. A known limitation
(ITL-1339): some operators (`PolarsFilter` and `MergeJoin`, likely `Join` and
`SemiJoin` too) return their rows in the default data context whatever their input's,
so in another data context a branch through one of them is refused beside a branch
that kept its context.
so in another data context the rows of a branch through one of them match nothing
beside a branch that kept its context.
- **Data columns are disjoint**, as in `Join`; a data-tag present in several inputs is one
column.
- **Different sources give nothing.** Two sources with the same schema have the same
Expand All @@ -241,6 +266,27 @@ print(units.select_data_columns(["rate"]).rejoin(other.select_data_columns(["dep
# 0
```

Two branches that set a shared tag to different values match nothing, with the warning:

```python
import warnings

from orcapod.errors import RejoinDifferingColumnWarning

first_run = units.select_data_columns(["rate"]).add_tags(run=1)
second_run = units.select_data_columns(["depth"]).add_tags(run=2)
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
print(first_run.rejoin(second_run).as_table().num_rows)
print([w.category.__name__ for w in caught if w.category is RejoinDifferingColumnWarning])
# 0
# ['RejoinDifferingColumnWarning']

same_run = units.select_data_columns(["depth"]).add_tags(run=1)
print(first_run.rejoin(same_run).as_table().num_rows)
# 3
```

!!! note "Provisional"
`Rejoin` is a provisional operator (ITL-1336): building one issues a
`ProvisionalHashWarning`, and its identity, so the hashes and stored paths of its
Expand Down Expand Up @@ -968,7 +1014,7 @@ November 19, 2026). Each name maps to the issue that decides its identity or out
| `Pick`, `Index` | the policy for a miss, which changes the output (ITL-439) |
| `PolarsFilter` | whether the order of its predicates belongs to its identity (ITL-1247) |
| `TagBy`, `AddTags` | days old, their identities just changed: the review of the tag operators (ITL-1290) |
| `Rejoin` | new: puts the branches of one stream back together by matching system tags (ITL-1336) |
| `Rejoin` | new: puts the branches of one stream back together by matching system tags (ITL-1336); its matching rule changed in this release (ITL-1355) |

Every other operator is frozen with data context v1: `Join`, `SemiJoin`, `MapData`, the
column selections (`SelectTagColumns`, `SelectDataColumns`, `DropTagColumns`,
Expand Down
Loading
Loading