Skip to content

feat(writer): add change-type splitter for delta writes - #3231

Open
laskoviymishka wants to merge 4 commits into
apache:mainfrom
laskoviymishka:feat/delta-ops-splitter
Open

laskoviymishka wants to merge 4 commits into
apache:mainfrom
laskoviymishka:feat/delta-ops-splitter

Conversation

@laskoviymishka

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Introduce the delta_writer module as the first building block for the DeltaWriter epic (#2218). Its record_ops::split_by_change_type takes a RecordBatch carrying the repo's _change_type column and splits it into separate insert and delete batches.

The _change_type column is located by name (RESERVED_COL_NAME_CHANGE_TYPE), wherever it sits in the schema, and must be a non-nullable Utf8 column whose values are all one of the four spec change types. Following Java's BaseDeltaTaskWriter, INSERT and UPDATE_AFTER rows collapse to inserts while DELETE and UPDATE_BEFORE rows collapse to deletes. The _change_type column is stripped from both outputs, preserving each payload column's field-id metadata and the schema-level metadata; input row order is preserved within each side. Anything violating the contract (missing/mistyped/nullable/null/out-of-domain _change_type, or no payload columns) is rejected as DataInvalid.

The module is pub(crate) since nothing wires it into a writer yet (that lands in a later PR of the epic).

Are these changes tested?

Newly added tests.

Introduce the delta_writer module as the first building block for the
DeltaWriter epic (apache#2218). Its record_ops::split_by_change_type takes a
RecordBatch carrying the repo's _change_type column and splits it into
separate insert and delete batches.

The _change_type column is located by name (RESERVED_COL_NAME_CHANGE_TYPE),
wherever it sits in the schema, and must be a non-nullable Utf8 column whose
values are all one of the four spec change types. Following Java's
BaseDeltaTaskWriter, INSERT and UPDATE_AFTER rows collapse to inserts while
DELETE and UPDATE_BEFORE rows collapse to deletes. The _change_type column is
stripped from both outputs, preserving each payload column's field-id metadata
and the schema-level metadata; input row order is preserved within each side.
Anything violating the contract (missing/mistyped/nullable/null/out-of-domain
_change_type, or no payload columns) is rejected as DataInvalid.

The module is pub(crate) since nothing wires it into a writer yet (that lands
in a later PR of the epic).
@laskoviymishka
laskoviymishka marked this pull request as ready for review September 15, 2026 20:02
Comment thread crates/iceberg/src/writer/delta_writer/mod.rs Outdated
Comment thread crates/iceberg/src/writer/delta_writer/record_ops.rs Outdated
Comment thread crates/iceberg/src/writer/delta_writer/mod.rs Outdated
Comment thread crates/iceberg/src/writer/delta_writer/record_ops.rs Outdated
…visibility, trim docs

Replace the manual payload-schema rebuild in split_by_change_type with RecordBatch::project, which drops the change-type column while carrying over each surviving field's metadata (field ids) and the schema-level metadata, instead of reimplementing an existing Arrow primitive.

Tighten SplitBatches, its fields, and split_by_change_type to pub(crate), matching the crate-internal delta_writer module and the change-type constants. The module stays behind allow(dead_code) until a writer consumes it.

Trim the module docs by dropping the epic link and the building-block comments that would go stale, keeping a one-line module purpose and the split_by_change_type Returns/Errors contract.
@laskoviymishka
laskoviymishka requested review from anoopj and blackmwk and removed request for anoopj September 23, 2026 19:41

This branch has not been deployed

No deployments
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.

2 participants