From 604e47e4b1e49716ddffa9bc890518f79e409d80 Mon Sep 17 00:00:00 2001 From: Leonid Ryzhyk Date: Mon, 24 Feb 2025 15:28:50 -0800 Subject: [PATCH] Workaround for compilation error due to rkyv#434. When datafusion is used in a workspace that enables the `rkyv-64` feature in the `chrono` crate, this triggered a Rust compilation error: ``` error[E0277]: can't compare `Option<&std::string::String>` with `Option<&mut std::string::String>`. ``` The root cause of the error is incorrect type unification in the Rust compiler, as explained in https://github.com/rkyv/rkyv/issues/434. The workaround pushes the compiler in the right direction by converting the mutable reference to an immutable one manually. Signed-off-by: Leonid Ryzhyk --- datafusion/expr/src/logical_plan/plan.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index 870b0751c923a..c6fd95595233e 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 = 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 }