Skip to content

compute: native columnar consolidate_named (F1)#37756

Draft
antiguru wants to merge 1 commit into
columnar-c4-linear-join-inputfrom
columnar-f1-consolidate
Draft

compute: native columnar consolidate_named (F1)#37756
antiguru wants to merge 1 commit into
columnar-c4-linear-join-inputfrom
columnar-f1-consolidate

Conversation

@antiguru

@antiguru antiguru commented Jul 20, 2026

Copy link
Copy Markdown
Member

Replace the decode, consolidate, re-encode round-trip in the Columnar arm of CollectionEdge::consolidate_named with a native columnar consolidation.

The old arm ran columnar_to_vec -> consolidate_named::<KeyBatcher> -> vec_to_columnar, allocating an owned Row per record in the decode.
The new columnar_consolidate helper stays columnar throughout: reshape into the ((Row, ()), T, Diff) key-batcher shape, merge via Col2KeyBatcher under a columnar_exchange pact, unpack back into a Column, all with borrowed pushes.

Uses consolidate_pact (the primitive the Vec arm already uses), not mz_arrange_core: a consolidate emits a consolidated collection, so building and reading back a maintained trace would be wasted work.
Col2KeyBatcher and the Vec arm's KeyBatcher produce the same ColumnationStack output and differ only in the input chunker, so the unpack loop matches the Vec arm's.

Temporary second variant; becomes the sole implementation at teardown T3.
Serves Union's concat_many -> consolidate_named path once Union inputs are columnar in Wave 2.
Producers still emit Vec, so the columnar arm is dead in production and this carries no runtime change.

Replace the decode, consolidate, re-encode round-trip in the `Columnar`
arm of `CollectionEdge::consolidate_named` with a native columnar
consolidation.

The old arm ran `columnar_to_vec` then `consolidate_named::<KeyBatcher>`
then `vec_to_columnar`, allocating an owned `Row` per record in the
decode. The new `columnar_consolidate` helper stays columnar throughout:
it reshapes each record into the `((Row, ()), T, Diff)` key-batcher
shape, merges via `Col2KeyBatcher` under a `columnar_exchange` pact, and
unpacks back into a `Column`. Rows, times, and diffs are pushed borrowed,
so no owned `Row` is materialized on the hot path.

This uses `consolidate_pact`, the same primitive the `Vec` arm uses, not
`mz_arrange_core`. A consolidate emits a consolidated collection, so
building and reading back a maintained trace would be wasted work.
`Col2KeyBatcher` and the `Vec` arm's `KeyBatcher` produce the same
`ColumnationStack` output and differ only in their input chunker, so the
unpack loop matches the `Vec` arm's.

This is the temporary second consolidate variant. At teardown T3 it
becomes the sole implementation. It serves Union's `concat_many` then
`consolidate_named` path once Union inputs are columnar in Wave 2.

Producers still emit `Vec`, so the columnar arm is dead in production and
this change carries no runtime behavior change.

The test `consolidate_named_preserves_columnar` now covers accumulation
and cancellation across two distinct timestamps and asserts the columnar
arm agrees with the `Vec` arm.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@antiguru
antiguru force-pushed the columnar-f1-consolidate branch from d3f26c9 to d74312c Compare July 20, 2026 20:06
Comment on lines +342 to +344
let consolidated = consolidate_pact::<batcher::Chunker<_>, Col2KeyBatcher<Row, T, Diff>, _, _>(
keyed, exchange, name,
);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a builder that produces Columnar chunks itself, so we wouldn't need the additional unpacking step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant