lance-format / lance-format/lance
Horizontal merge insert should not rewrite join columns
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7.1k
- Forks
- 852
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 272
Description
When we perform a horizontal merge_insert we rewrite all columns that are modified. The join column cannot be modified and should not have to be rewritten.
However, we are rewriting the join column, which is slightly wasteful.
import lance
import pyarrow as pa
import shutil
shutil.rmtree("/tmp/test_dataset", ignore_errors=True)
ds = lance.write_dataset(pa.table({"id": range(100), "value": range(100), "other": range(100)}), "/tmp/test_dataset")
ds.merge_insert("id").when_matched_update_all().when_not_matched_insert_all().execute(pa.table({"id": range(50, 150), "value": range(50, 150)}))
frag = ds.get_fragments()[0]
data_file = frag.data_files()[0]
print(f"Fields={data_file.fields}") # This is actually [-2, -2, 2]
assert data_file.fields == [0, -2, 2]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the merge_insert entry point shown in the Python reproduction and trace its Rust implementation to where updated fields are selected for horizontal merges. Use the supplied dataset and assertion to inspect the resulting data_file.fields. Done means the join column remains unchanged while modified columns are rewritten, with the reproduction passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- data-engineering, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100