feat: add update_columns_from API - #5281
Conversation
a2a5858 to
b066daf
Compare
4bf8254 to
70c57fa
Compare
|
@yanghua Hi, all checks have passed. Could you please take a look at this PR when free? Thanks very much !!! |
Empty from_arrow sources have no lineage, so a missing target column must fail on schema rather than on the later read_version requirement.
Rationale for two intentionally unchanged review items
References: Ray |
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