lance-format / lance-format/lance
Better handle schema mismatch when writing dataset
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7.1k
- Forks
- 852
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 272
Description
import pyarrow as pa
import lance
t = pa.Table.from_pylist([{"test": [1, 2, 3]}])
ds = lance.write_dataset(
t,
"test.lance",
schema=pa.schema([pa.field("test", pa.list_(pa.float32(), 32))]),
mode="overwrite",
)
print(f"===> schema with pa.Table: \n{t.schema}, lance: \n{ds.schema}")
batch = pa.RecordBatch.from_pylist([{"test": [1, 2, 3]}])
ds = lance.write_dataset(
pa.RecordBatch.from_pylist([{"test": [1, 2, 3]}]),
"test.lance",
schema=pa.schema([pa.field("test", pa.list_(pa.float32(), 32))]),
mode="overwrite",
)
print(f"===> schema with pa.RecordBatch: \n{batch.schema}, lance: \n{ds.schema}")
lance.write_dataset(
[pa.RecordBatch.from_pylist([{"test": [1, 2, 3]}])],
"test.lance",
schema=pa.schema([pa.field("test", pa.list_(pa.float32(), 32))]),
mode="overwrite",
)
the above script yields output:
===> schema with pa.Table:
test: list<item: int64>
child 0, item: int64, lance:
test: list<item: int64>
child 0, item: int64
===> schema with pa.RecordBatch:
test: list<item: int64>
child 0, item: int64, lance:
test: list<item: int64>
child 0, item: int64
munmap_chunk(): invalid pointer
[1] 472488 IOT instruction (core dumped) python test.py
In the first two cases, maybe we should print a warning about setting schema= when the data source is pa.Table | pa.RecordBatch, where the specified schema is ignored.
In the third case, we crash on abort because the list of record batch and schema mismatches. (ideally user would call with RBR, but sometime just passing a list of RecordBatches is convenient.0
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 by reproducing the issue with the shown Python script and inspect the write_dataset entry point for pa.Table, pa.RecordBatch, and lists of RecordBatches. Done means the requested schema is handled consistently or clearly warned about, and a mismatched list of batches produces a safe error instead of aborting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- data-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100