Repository: apache/datafusion (language: rust)

Issue:
Compilation error due to rkyv/rkyv#434
### Describe the bug

When datafusion is used in a workspace that enables the `rkyv-64` feature in the `chrono` crate, this triggers a Rust compilation error:
    
```
error[E0277]: can't compare `Option<&std::string::String>` with `Option<&mut std::string::String>`
    --> datafusion/expr/src/logical_plan/plan.rs:2872:43
     |
2872 |         merged.retain(|k, v| input.get(k) == Some(v));
     |                                           ^^ no implementation for `Option<&std::string::String> == Option<&mut std::string::String>`
     |
     = help: the trait `PartialEq<Option<&mut std::string::String>>` is not implemented for `Option<&std::string::String>`
     = help: the following other types implement trait `PartialEq<Rhs>`:
               `Option<T>` implements `PartialEq`
               `Option<U>` implements `PartialEq<rkyv::option::ArchivedOption<T>>`
```

The root cause of the error is incorrect type unification in the Rust compiler, as explained in https://github.com/rkyv/rkyv/issues/434.

I will submit a PR with a workaround.

### To Reproduce

Change `Cargo.toml` to enable the `rkyv-64` feature in chrono and try building the `datafusion-expr` crate:

```
chrono = { version = "0.4.38", default-features = false, features = ["rkyv-64"] }
```

### Expected behavior

_No response_

### Additional context

_No response_


Discussion / hints:

Fix patch:
diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs
index 870b0751c923..c6fd95595233 100644
--- a/datafusion/expr/src/logical_plan/plan.rs
+++ b/datafusion/expr/src/logical_plan/plan.rs
@@ -2869,7 +2869,11 @@ fn intersect_maps<'a>(
     let mut inputs = inputs.into_iter();
     let mut merged: HashMap<String, String> = inputs.next().cloned().unwrap_or_default();
     for input in inputs {
-        merged.retain(|k, v| input.get(k) == Some(v));
+        // The extra dereference below (`&*v`) is a workaround for https://github.com/rkyv/rkyv/issues/434.
+        // When this crate is used in a workspace that enables the `rkyv-64` feature in the `chrono` crate,
+        // this triggers a Rust compilation error:
+        // error[E0277]: can't compare `Option<&std::string::String>` with `Option<&mut std::string::String>`.
+        merged.retain(|k, v| input.get(k) == Some(&*v));
     }
     merged
 }


Test patch: