mirror of
https://github.com/lancedb/lancedb.git
synced 2026-03-23 17:10:39 +00:00
fix: propagate cast errors in add() (#3075)
When we write data with `add()`, we can input data to the table's schema. However, we were using "safe" mode, which propagates errors as nulls. For example, if you pass `u64::max` into a field that is a `u32`, it will just write null instead of giving overflow error. Now it propagates the overflow. This is the same behavior as other systems like DuckDB. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -326,6 +326,24 @@ def test_add_struct(mem_db: DBConnection):
|
||||
table = mem_db.create_table("test2", schema=schema)
|
||||
table.add(data)
|
||||
|
||||
struct_type = pa.struct(
|
||||
[
|
||||
("b", pa.int64()),
|
||||
("a", pa.int64()),
|
||||
]
|
||||
)
|
||||
expected = pa.table(
|
||||
{
|
||||
"s_list": [
|
||||
[
|
||||
pa.scalar({"b": 1, "a": 2}, type=struct_type),
|
||||
pa.scalar({"b": 4, "a": None}, type=struct_type),
|
||||
]
|
||||
],
|
||||
}
|
||||
)
|
||||
assert table.to_arrow() == expected
|
||||
|
||||
|
||||
def test_add_subschema(mem_db: DBConnection):
|
||||
schema = pa.schema(
|
||||
|
||||
Reference in New Issue
Block a user