feat(writer): add change-type splitter for delta writes - #3231
Open
laskoviymishka wants to merge 4 commits into
Open
laskoviymishka wants to merge 4 commits into
laskoviymishka wants to merge 4 commits into
Conversation
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
marked this pull request as ready for review
September 15, 2026 20:02
anoopj
reviewed
Sep 16, 2026
anoopj
reviewed
Sep 16, 2026
anoopj
reviewed
Sep 16, 2026
anoopj
reviewed
Sep 16, 2026
…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
requested review from
anoopj and
blackmwk
and removed request for
anoopj
September 23, 2026 19:41
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.