Python write_deltalake
with schema_mode="merge"
casts types
#2642
Labels
write_deltalake
with schema_mode="merge"
casts types
#2642
Environment
Delta-rs version: 0.18.1 (Python
deltalake
0.18.1)Binding:
Environment:
Bug
What happened:
Using
write_deltalake
to append data to a table withschema_mode="merge"
, if I change the type of a field in a struct, the data is cast to the existing table schema (e.g. a string"1"
becomes an int1
) instead of raising an error because I'm trying to merge incompatible schemas.What you expected to happen:
When a field's type changes, I'd expect the merge to fail. (Unless I deliberately configure something like type widening int32 to int64 etc.)
How to reproduce it:
Here, a struct contains a field
"x"
which changes from int64 to string, the table schema is printed before and after, and the final data shows the string has been cast to an intPrints:
The schema is the same after writing the new data containing a string, and the string has been cast to an int
I don't know whether this is a bug or a feature request. I see some mention of type casting in the code but couldn't find it in docs.
I'd like to be able to merge schemas in a way which will raise an exception if types have changed, unless I enable a setting for type casting (or similar). Let me know if more info would be useful, or if you want me to check more cases
The text was updated successfully, but these errors were encountered: