Repository navigation
feat: add update_columns_from API - #5281
hfutatzhanghb wants to merge 21 commits into
Conversation
4bf8254 to
70c57fa
Compare
|
@yanghua Hi, all checks have passed. Could you please take a look at this PR when free? Thanks very much !!! |
Rationale for two intentionally unchanged review items
References: Ray |
|
@yanghua Hi, sir. Please take a look at this PR again when have free time, Thanks! |
|
Will take a look today! |
| op = LanceOperation.Update( | ||
| updated_fragments=updated_fragments, | ||
| fields_modified=list(all_fields_modified), | ||
| ) |
There was a problem hiding this comment.
Do we need to set update_mode="rewrite_columns" ?
There was a problem hiding this comment.
Good catch — yes. This path uses LanceFragment.update_columns(), so the transaction has rewrite_columns semantics. I set update_mode="rewrite_columns" explicitly and added a regression test that captures the committed operation and verifies the mode. Fixed in 1c76f78.
Empty from_arrow sources have no lineage, so a missing target column must fail on schema rather than on the later read_version requirement.
1c76f78 to
046250a
Compare
Ray 2.56 turns arrow-backed pandas conversion on by default, so astype(str) becomes pa.string() and the driver rejects the ambiguous schema before the worker can. Disable that conversion in the mismatch test. Commit rewrite_columns with matched fragment offsets so stable row versions update, return the matched row count, and detect duplicate row addresses with a k-way merge. Keep provenance off Ray plan names, include environment object-store endpoints in dataset identity, and align blob block metadata with the large_binary values readers yield.
Summary
lance_ray.update_columns_from()for fragment-local updates of existing columns using Lance row addresses.Background
Lance Spark exposes
UPDATE COLUMNS FROM, which updates existing columns by matching row metadata. UnlikeMERGE INTO, it uses Lance's fragment update path and avoids a global hash join and full-row rewrites.Lance-Ray currently has additive data-evolution APIs (
add_columns,add_columns_from, andmerge_columns_from), but no equivalent fragment-level API for updating existing columns. This PR adds that primitive.API
The source Ray Dataset must contain
_rowaddrand every requested update column._fragidis optional: it is derived from_rowaddrwhen absent and validated against the encoded fragment ID when supplied.Unmatched source rows are ignored. This API only updates existing columns; it does not insert, delete, or upsert rows.
Changes
lance_ray/io.pyupdate_columns_from()_rowaddr/_fragidvalues touint64_fragidand callfragment.update_columns(..., left_on="_rowaddr", right_on="_rowaddr")LanceOperation.Updateonce against the resolved source version and surface conflicts without retrying stale workmap_groups()lance_ray/__init__.py: exportupdate_columns_from.docs/src/data-evolution.md: document the API contract and conflict behavior.tests/test_update_columns_from.py: cover partial and filtered updates, metadata preservation, schema and row-address validation, source-version conflicts, remote arguments, batch sizing, and namespace mode.Validation
python -m ruff check lance_ray/io.py lance_ray/__init__.py tests/test_update_columns_from.pypython -m ruff format --check lance_ray/io.py lance_ray/__init__.py tests/test_update_columns_from.pyuv run mypypytest tests/test_update_columns_from.py -q