chsgray opened a new issue, #15351:
URL: https://github.com/apache/datafusion/issues/15351

   ### Describe the bug
   
   Using the `delta-rs` Python binding, a `DeltaError` was raised when 
attempting a `DeltaTable.merge` operation. Library-assigned map field names 
appear to be mutually incompatible, which is beyond the user's control.
   
   The error looks like this:
   `DeltaError: Generic DeltaTable error: type_coercion
   caused by
   Error during planning: Failed to coerce then ([Map(Field { name: "entries", 
data_type: Struct([Field { name: "key", data_type: Utf8, nullable: false, 
dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "value", 
data_type: Float64, nullable: true, dict_id: 0, dict_is_ordered: false, 
metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, 
metadata: {} }, false), Map(Field { name: "entries", data_type: Struct([Field { 
name: "key", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: 
false, metadata: {} }, Field { name: "value", data_type: Float64, nullable: 
true, dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: false, 
dict_id: 0, dict_is_ordered: false, metadata: {} }, false), Map(Field { name: 
"key_value", data_type: Struct([Field { name: "key", data_type: Utf8, nullable: 
false, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: 
"value", data_type: Float64, nullable: true, dict_id: 0, dict_is_ordered: 
false, metada
 ta: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} 
}, false), Map(Field { name: "key_value", data_type: Struct([Field { name: 
"key", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, 
metadata: {} }, Field { name: "value", data_type: Float64, nullable: true, 
dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: false, dict_id: 
0, dict_is_ordered: false, metadata: {} }, false), Map(Field { name: 
"key_value", data_type: Struct([Field { name: "key", data_type: Utf8, nullable: 
false, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: 
"value", data_type: Float64, nullable: true, dict_id: 0, dict_is_ordered: 
false, metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, 
metadata: {} }, false)]) and else (None) to common types in CASE WHEN 
expression`
   
   See linked `delta-rs` bug report below for full traceback.
   
   ### To Reproduce
   
   Environment
   - Python 3.11 on Ubuntu
   - Datafusion version: 
[45](https://github.com/delta-io/delta-rs/blob/python-v0.25.4/Cargo.toml)
   - Delta-rs version: 0.25.4
   - Pandas version: 2.2.3
   - Pyarrow version: 18.1.0
   
   Python code
   ```python
   import pyarrow as pa
   import pandas as pd
   import deltalake
   
   path = "~/tmp/test"
   
   schema = pa.schema(
       [
           pa.field(
               "foo",
               pa.int64(),
               nullable=False,
           ),
           pa.field(
               "bar",
               pa.map_(pa.string(), pa.float64()),
               nullable=True,
           ),
       ]
   )
   
   df = pd.DataFrame(data={"foo": 1, "bar": [{"baz": 123.4}]})
   
   deltalake.write_deltalake(
       path,
       pa.Table.from_pandas(df, schema),
       mode="append"
   )
   
   (
       deltalake.DeltaTable(path)
       .merge(
           pa.Table.from_pandas(df, schema),
           predicate="s.foo = t.foo",
           target_alias="t",
           source_alias="s",
       )
       .when_matched_update_all()
       .when_not_matched_insert_all()
       .execute()
   )
   ```
   
   ### Expected behavior
   
   I expected the `merge` operation to succeed.
   
   ### Additional context
   
   `delta-rs` maintainers indicated this issue is upstream of their library, 
which is why I'm raising this here.
   
   The issue I raised there: 
[link](https://github.com/delta-io/delta-rs/issues/3340)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to