From 4048150fdd3bc19d7c651f1e4e7e16c82b6b5888 Mon Sep 17 00:00:00 2001 From: "lancedb-gatefixer[bot]" <313497061+lancedb-gatefixer[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 17:31:19 +0800 Subject: [PATCH] test(python): cover nullable fixed-size-list ingestion (#3812) ## Summary - add regression coverage for adding dictionary rows with a nullable fixed-size-list column - verify ordinary list columns remain aligned alongside the null fixed-size-list value ## Root cause PyArrow infers an all-`None` dictionary column as the generic `null` type. The original schema-alignment path treated the target fixed-size-list type as proof that the inferred source was also list-like and unconditionally accessed `value_field`, which raised `AttributeError`. Current alignment logic correctly falls back to the target type when the source is not list-like; this test locks in that repair for the reported ingestion path. ## Validation - `uv run --extra tests pytest python/tests/test_table.py::test_add_with_empty_fixed_size_list_drops_bad_rows python/tests/test_table.py::test_add_nullable_fixed_size_list_with_none python/tests/test_table.py::test_add_nullable_struct_with_none -q` - `uv run --with pyarrow==19.0.1 --extra tests pytest python/tests/test_table.py::test_add_nullable_fixed_size_list_with_none -q` - `uv run --project python --extra dev ruff format --check python/python/tests/test_table.py` - `uv run --project python --extra dev ruff check .` Fixes #2340 Co-authored-by: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com> --- python/python/tests/test_table.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/python/python/tests/test_table.py b/python/python/tests/test_table.py index b2bfa2a68..e5c4ad801 100644 --- a/python/python/tests/test_table.py +++ b/python/python/tests/test_table.py @@ -1845,6 +1845,27 @@ def test_add_with_empty_fixed_size_list_drops_bad_rows(mem_db: DBConnection): assert np.allclose(data["embedding"].to_pylist()[0], np.array([0.1] * 16)) +def test_add_nullable_fixed_size_list_with_none(mem_db: DBConnection): + """Regression test for issue #2340.""" + table = mem_db.create_table( + "test_nullable_fixed_size_list", + schema=pa.schema( + [ + pa.field("id", pa.string()), + pa.field("feature", pa.list_(pa.float32(), 256)), + pa.field("tags", pa.list_(pa.string())), + ] + ), + ) + + table.add([{"id": "1", "feature": None, "tags": ["tag1", "tag2"]}]) + + result = table.to_arrow() + assert result.to_pylist() == [ + {"id": "1", "feature": None, "tags": ["tag1", "tag2"]} + ] + + def test_add_nullable_struct_with_none(mem_db: DBConnection): """Regression test for issue #2654: a nullable struct column whose first batch contains only None values must not crash in