refactor: de-duplicate the streaming write_lance commit path#5197
Open
LuciferYang wants to merge 1 commit into
Open
refactor: de-duplicate the streaming write_lance commit path#5197LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
The streaming path repeated the open-dataset-to-read-version block four times and the create-mode initial_bases expression twice. Extract _open_lance_version / _refresh_version helpers, compute the overwrite initial bases once, and collapse the first-commit branches (the old three-way branch had an unreachable overwrite fallback for valid modes). Behavior is unchanged for create/append/overwrite.
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.
The streaming
write_lancepath (one fragment committed per batch) had grown repetitive: the "reopen the dataset to read its new version" block was copy-pasted four times, the create-modeinitial_basesexpression appeared twice, and the first-commit branch had a third arm that was unreachable for any valid mode.This pulls the reopen logic into two helpers —
_open_lance_version, and_refresh_versionwhich keeps the previous version if the reopen fails — computes the overwrite bases once, and collapses the first-commit handling into "append onto an existing dataset, otherwise overwrite". The localimport lancegoes away since the top-levelLanceDatasetis already used everywhere.Behavior is unchanged for create, append, and overwrite — I diffed the streaming output and version progression against the old code across create / append / overwrite / overwrite-into-a-new-path / resume and they match exactly. Added a streaming create-then-append test alongside the existing blob streaming coverage.