Skip to content

feat: add table-aware position delete updates - #919

Open
wirybeaver wants to merge 1 commit into
apache:mainfrom
wirybeaver:feature/v3-dv-write-pipeline
Open

wirybeaver wants to merge 1 commit into
apache:mainfrom
wirybeaver:feature/v3-dv-write-pipeline

Conversation

@wirybeaver

@wirybeaver wirybeaver commented Sep 5, 2026 •

Copy link
Copy Markdown

Motivation

DV-PR-1 in #916 lets callers delete a row by data file and position. A second delete on the same v3 file must preserve positions deleted by the first commit.

Modification

Resolve each live file's partition and spec, and check the requested positions against its record count before creating output. Commit through RowDelta, which validates that the referenced data files still exist.

file + positions -> resolve live file -> v2: write sorted Parquet deletes
                                      -> v3: merge prior deletes into a Puffin DV
                 -> commit new entries and supersede rewritten deletes

A definite commit failure cleans up generated files. An unknown commit outcome preserves them because the catalog may already reference them.

Test

The in-library end-to-end test uses real Parquet and Puffin encoding with Arrow MockFileSystem and InMemoryCatalog.

  • It writes five rows, deletes positions 3 and 1, commits, and reloads the table. The scan returns rows 0, 2, and 4.
  • After partition evolution, a second delete at position 2 leaves exactly rows 0 and 4 on reload.
  • An upgrade scenario verifies that a v3 DV incorporates earlier v2 Parquet deletes.

@zhjwpku

zhjwpku commented Nov 20, 2026

Copy link
Copy Markdown
Member

@wirybeaver is this ready for review?

@wirybeaver
wirybeaver marked this pull request as ready for review November 20, 2026 07:25
@wirybeaver
wirybeaver force-pushed the feature/v3-dv-write-pipeline branch from f43d28c to 2bd9494 Compare November 20, 2026 07:32
@wirybeaver

Copy link
Copy Markdown
Author

Hi, @zhjwpku feel free to take a review. I rebase the most recent and updated the PR body

@zhjwpku

zhjwpku commented Nov 20, 2026

Copy link
Copy Markdown
Member

Hi, @zhjwpku feel free to take a review. I rebase the most recent and updated the PR body

CI failed, please take a look when available, thanks.

@wirybeaver
wirybeaver force-pushed the feature/v3-dv-write-pipeline branch from 2bd9494 to 1c49395 Compare November 20, 2026 18:17
@wirybeaver

wirybeaver commented Nov 20, 2026 •

Copy link
Copy Markdown
Author

Hi @zhjwpku , I updated FileIO to treat only ENOENT from the delete operation as success. Deleting a bucket-only S3 URI now propagates the original error. The previously failing AWS test passes locally.

@wgtmac

wgtmac commented Nov 25, 2026

Copy link
Copy Markdown
Member

What use case do we have in mind for PositionDeleteUpdate? For an engine that obtains (path, pos) from a scan, the existing C++ APIs already fit together fairly directly:

  • In v2, group positions by data file, sort them, and pass them to PositionDeleteWriter::WriteDelete.
  • In v3, pass the file’s spec and partition to DVWriter::Delete. Its load_previous_deletes callback can use DeleteLoader with the position delete files already attached to the scan task. DVWriter::Metadata() then tells the caller which files to add and which old delete entries to remove.
  • In both cases, commit through RowDelta, using ValidateFromSnapshot with the snapshot the engine actually read and ValidateDataFilesExist for the referenced files. This is also how the Java Spark integration composes its writers and RowDelta.

That lets the engine reuse its original scan tasks, read prior deletes with the scan’s FileIO, and validate against the same snapshot that produced the row positions. The proposed (path, pos) interface drops that context, so Commit() has to plan another scan. With REST planning, that second scan can resolve against a different snapshot, and the current implementation also loses the scan-scoped credentials when it reads prior deletes.

Given that, I’d prefer to hold this PR until there is a clear use case.

@wirybeaver

wirybeaver commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

@wgtmac The intended caller is an engine that has already identified the rows to delete. A shared API would let each engine report those positions while Iceberg handles the version-specific work. In v2, that means writing sorted position deletes. In v3, it means merging new positions with prior deletes and atomically replacing the superseded delete entries.

I agree that (path, pos) loses the original scan context. I’ve revised this locally as an internal helper. It takes positions grouped by the original FileScanTask, reads prior deletes with the scan’s FileIO, and returns the delete entries to add and remove. The caller commits them through RowDelta using the original snapshot ID, so there’s no second planning pass.

The follow-up PR #1182 uses this helper for a filter-based merge-on-read delete. Iceberg Go uses a similar split in its delete operation.

@wirybeaver
wirybeaver force-pushed the feature/v3-dv-write-pipeline branch from e1b9600 to 571f75b Compare November 26, 2026 21:27

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.

3 participants