-
Notifications
You must be signed in to change notification settings - Fork 424
Open
Labels
Milestone
Description
Currently, lance does not allow null in struct. Be able to serialize null structs on disk in format v2.1
import lance
import pyarrow as pa
schema = pa.schema(
[
pa.field("id", pa.int64()),
pa.field(
"point",
pa.struct(
[
pa.field("x", pa.float64(), nullable=True),
pa.field("y", pa.float64(), nullable=True),
pa.field("z", pa.float64(), nullable=True),
],
),
nullable=True,
),
]
)
tbl = pa.Table.from_pylist([{"id": 5, "point": None}], schema=schema)
print("origin: ", tbl.to_pydict())
lance.write_dataset(tbl, "empty.lance", schema=schema, data_storage_version="2.1")
ds = lance.dataset("empty.lance")
tbl = ds.to_table()
print(tbl.to_pydict())
Output
origin: {'id': [5], 'point': [None]}
[2025-08-04T15:35:35Z WARN lance_file::v2::writer] You have requested an unstable format version. Files written with this format version may not be readable in the future! This is a development feature and should only be used for experimentation and never for production data.
{'id': [5], 'point': [{'x': 0.0, 'y': 0.0, 'z': 0.0}]}