diff --git a/datafusion/physical-expr/src/equivalence/properties.rs b/datafusion/physical-expr/src/equivalence/properties.rs index 57c0cfb952b48..cf70a884028e5 100644 --- a/datafusion/physical-expr/src/equivalence/properties.rs +++ b/datafusion/physical-expr/src/equivalence/properties.rs @@ -1843,6 +1843,11 @@ fn calculate_union_binary( .map(|rhs_const| { let mut const_expr = ConstExpr::new(Arc::clone(lhs_const.expr())); + // If both sides are constant across partitions, set across_partitions=true + if lhs_const.across_partitions() && rhs_const.across_partitions() { + const_expr = const_expr.with_across_partitions(true); + } + // If both sides have matching constant values, preserve the value and set across_partitions=true if let (Some(lhs_val), Some(rhs_val)) = (lhs_const.value(), rhs_const.value())