fix: restore blanks for empty batches and split oversized writes in updater#7318
Open
zhangyang0418 wants to merge 1 commit into
Open
fix: restore blanks for empty batches and split oversized writes in updater#7318zhangyang0418 wants to merge 1 commit into
zhangyang0418 wants to merge 1 commit into
Conversation
…pdater Following the fix for lance-format#7232, two further issues surface when a fully deleted batch sits in the *middle* of a fragment and columns are added/merged (e.g. via `Fragment::merge_columns` + `LanceOperation::Merge`): - `add_blanks` returned `NotSupported` ("Missing too many rows in merge, run compaction to materialize deletions first") whenever the input batch was empty but deleted offsets still needed restoring. It now builds null rows with `new_null_array`, so blanks are restored regardless of whether the input batch is empty. - When restoring deleted rows the `DeletionRestorer` greedily appends trailing deleted rows to the preceding batch, which can grow it past the requested `batch_size`. `Updater::update` now slices the restored batch back down to the write batch size before writing, keeping output file batches bounded. Adds Rust unit tests (`add_blanks` on an empty batch, `add_columns` with a middle fully-deleted batch) and a Python regression test exercising `merge_columns` + commit over a dataset with a deletion file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Xuanwo
reviewed
Jun 19, 2026
| .schema() | ||
| .fields() | ||
| .iter() | ||
| .map(|field| new_null_array(field.data_type(), batch_offsets.len())) |
Collaborator
There was a problem hiding this comment.
Restoring an empty batch with null placeholders still fails when the first read batch is fully deleted and the added column is non-nullable, so valid add/merge-column operations can error before returning any visible rows.
| // SPDX-FileCopyrightText: Copyright The Lance Authors | ||
|
|
||
| use arrow_array::{RecordBatch, UInt32Array}; | ||
| use arrow_array::{new_null_array, RecordBatch, UInt32Array}; |
Collaborator
There was a problem hiding this comment.
The new import order is not rustfmt-formatted, so the format and lint jobs fail before the PR reaches the rest of the Rust checks.
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.
What
Follow-up to #7233. Fixes two more failures that occur when a fully deleted batch sits in the middle of a fragment and columns are added/merged (e.g. via
Fragment::merge_columns+LanceOperation::Merge).Root cause
After #7233 handled the 0-row batch at a read boundary, two related issues remain in
updater.rs:add_blanksrejects empty batches.DeletionRestorerwalks the deletion vector and may need to insert blanks for deleted rows that land on a batch whose live rows are all elsewhere, producing an empty input batch with non-empty offsets.add_blanksreturnedNotSupported("Missing too many rows in merge, run compaction to materialize deletions first") in that case.batch_size.DeletionRestorergreedily appends trailing deleted rows to the preceding batch, so the restored batch can be larger than the requestedbatch_size, producing oversized output file batches.Fix
add_blanksnow builds null rows vianew_null_arrayfor an empty input batch instead of erroring.Updater::updateslices the restored batch back down to the write batch size before writing.Tests
add_blanksunit test on an empty batch.add_columnsRust test with a middle fully-deleted batch.merge_columns+ commit over a dataset with a deletion file.