feat: implement native update path with stable row-id preservation#407
Draft
ivscheianu wants to merge 2 commits intolance-format:mainfrom
Draft
feat: implement native update path with stable row-id preservation#407ivscheianu wants to merge 2 commits intolance-format:mainfrom
ivscheianu wants to merge 2 commits intolance-format:mainfrom
Conversation
Contributor
|
ACTION NEEDED The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. For details on the error please inspect the "PR Title Check" action. |
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.
Fix for #406
Summary
Reworks
SparkPositionDeltaWrite(Spark 3.5) to use Spark's nativeDeltaWriter.update()method instead ofrepresentUpdateAsDeleteAndInsert(), enabling stable row-ID preservation across updates.Problem
The previous implementation threw
UnsupportedOperationExceptionfromupdate(), forcing Spark to decompose updates into separate delete + insert operations. This prevented the connector from knowing which_rowidmaps to which newly written row, making it impossible to attachRowIdMetato newfragments. Without
RowIdMeta, lance-core cannot trace updated rows back to their originals, breaking_row_created_at_versiontracking and stable row-ID continuity.Additionally, each worker opened its own
Datasetto apply deletions, causing unnecessary I/O and potential race conditions.Changes
Spark 3.5 (
SparkPositionDeltaWrite):update(): capture_rowidfrom the id row, record deletion via_rowaddr, and write the data row — all in one call.commit(): if stable row IDs are enabled, attachRowIdMetato new fragments usingRowIdMeta.fromRowIds()(from companion lance PR).Map<fragmentId, RoaringBitmap>to the driver, which consolidates and applies deletions in a singleDatasetsession.useStableRowIds(true)onCommitBuilderwhen the dataset has them.Spark 3.4 (
SparkPositionDeltaWrite):update()).CDF test expectation corrections:
BaseCdfVersionTrackingTest,BaseCdfConfigTest,BaseCdfQueryPatternsTest: updated_row_created_at_versionexpectations from1to the actual inser version (typically2). Previously tests passed only because the JNI gap in lance-core was silently dropping version metadata.Companion PR
This PR depends on lance-format/lance#6465 which fixes the JNI version metadata serialization gap and the row-ID lookup bug in
Operation::Update. Both PRs are needed for correct end-to-end_row_created_at_versiontracking.