create_table crashes with IndexError on an all-null vector column
Description
create_table(data=...) without an explicit schema raises IndexError: index out of bounds when a list/large_list column whose name contains vector/embedding has all-null values.
import tempfile, lancedb, pyarrow as pa
db = lancedb.connect(tempfile.mkdtemp())
data = pa.table({
"id": pa.array([1, 2], type=pa.int64()),
# valid: vector column is typed list<float32>, embeddings not computed yet
"vector": pa.array([None, None], type=pa.list_(pa.float32())),
})
db.create_table("t", data=data)
# IndexError: index out of bounds_modal_list_size (python/python/lancedb/table.py) infers the vector dimension with pc.mode(pc.list_value_length(arr))[0]. pyarrow's mode skips nulls, so an all-null column yields a zero-length result and the [0] subscript raises.
The sibling helper _infer_vector_dim in the same file performs the identical pc.mode(...) and already guards the empty case with if len(lengths) == 0: return None, so this is a case that was meant to be handled — _modal_list_size just missed it.
An all-null vector column is a realistic input: you often create the table with the schema in place and the embeddings filled in later.
Expected
create_table succeeds and leaves the column as a variable-length list (the dimension is genuinely unknowable when every value is null), rather than crashing.
I have a fix (return None from _modal_list_size when all-null and skip the fixed-size dimension at the call site, mirroring _infer_vector_dim) plus a regression test, and will open a PR.
Source: lancedb/lancedb