This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch branch-53
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/branch-53 by this push:
     new e88a5faaef [branch-53] fix: do not recompute hash join exec properties 
if not required (#20900) (#20903)
e88a5faaef is described below

commit e88a5faaefaca163039595f6c8884e0f0abf2ad3
Author: Andrew Lamb <[email protected]>
AuthorDate: Thu Mar 12 11:52:12 2026 -0400

    [branch-53] fix: do not recompute hash join exec properties if not required 
(#20900) (#20903)
    
    - Part of https://github.com/apache/datafusion/issues/19692
    - Backports https://github.com/apache/datafusion/pull/20900 from @askalt
    to the branch-53 line
    
    This PR:
    - Backports https://github.com/apache/datafusion/pull/20900 to branch-53
    
    Co-authored-by: Albert Skalt <[email protected]>
---
 datafusion/physical-plan/src/execution_plan.rs       | 7 +++++--
 datafusion/physical-plan/src/joins/hash_join/exec.rs | 7 +++++--
 datafusion/physical-plan/src/sorts/sort.rs           | 2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/datafusion/physical-plan/src/execution_plan.rs 
b/datafusion/physical-plan/src/execution_plan.rs
index 681a1345d8..d1d7b62b53 100644
--- a/datafusion/physical-plan/src/execution_plan.rs
+++ b/datafusion/physical-plan/src/execution_plan.rs
@@ -1428,7 +1428,7 @@ pub fn reset_plan_states(plan: Arc<dyn ExecutionPlan>) -> 
Result<Arc<dyn Executi
 /// replace is requested.
 /// The size of `children` must be equal to the size of 
`ExecutionPlan::children()`.
 pub fn has_same_children_properties(
-    plan: &Arc<impl ExecutionPlan>,
+    plan: &impl ExecutionPlan,
     children: &[Arc<dyn ExecutionPlan>],
 ) -> Result<bool> {
     let old_children = plan.children();
@@ -1451,7 +1451,10 @@ pub fn has_same_children_properties(
 #[macro_export]
 macro_rules! check_if_same_properties {
     ($plan: expr, $children: expr) => {
-        if $crate::execution_plan::has_same_children_properties(&$plan, 
&$children)? {
+        if $crate::execution_plan::has_same_children_properties(
+            $plan.as_ref(),
+            &$children,
+        )? {
             let plan = $plan.with_new_children_and_same_properties($children);
             return Ok(::std::sync::Arc::new(plan));
         }
diff --git a/datafusion/physical-plan/src/joins/hash_join/exec.rs 
b/datafusion/physical-plan/src/joins/hash_join/exec.rs
index eda7e93eff..f9fa9f6eb2 100644
--- a/datafusion/physical-plan/src/joins/hash_join/exec.rs
+++ b/datafusion/physical-plan/src/joins/hash_join/exec.rs
@@ -23,7 +23,10 @@ use std::sync::{Arc, OnceLock};
 use std::{any::Any, vec};
 
 use crate::ExecutionPlanProperties;
-use crate::execution_plan::{EmissionType, boundedness_from_children, 
stub_properties};
+use crate::execution_plan::{
+    EmissionType, boundedness_from_children, has_same_children_properties,
+    stub_properties,
+};
 use crate::filter_pushdown::{
     ChildFilterDescription, ChildPushdownResult, FilterDescription, 
FilterPushdownPhase,
     FilterPushdownPropagation,
@@ -372,9 +375,9 @@ impl HashJoinExecBuilder {
             children.len() == 2,
             "wrong number of children passed into `HashJoinExecBuilder`"
         );
+        self.preserve_properties &= has_same_children_properties(&self.exec, 
&children)?;
         self.exec.right = children.swap_remove(1);
         self.exec.left = children.swap_remove(0);
-        self.preserve_properties = false;
         Ok(self)
     }
 
diff --git a/datafusion/physical-plan/src/sorts/sort.rs 
b/datafusion/physical-plan/src/sorts/sort.rs
index 5b64f0b2a6..b1b44cb102 100644
--- a/datafusion/physical-plan/src/sorts/sort.rs
+++ b/datafusion/physical-plan/src/sorts/sort.rs
@@ -1196,7 +1196,7 @@ impl ExecutionPlan for SortExec {
         assert_eq!(children.len(), 1, "SortExec should have exactly one 
child");
         new_sort.input = Arc::clone(&children[0]);
 
-        if !has_same_children_properties(&self, &children)? {
+        if !has_same_children_properties(self.as_ref(), &children)? {
             // Recompute the properties based on the new input since they may 
have changed
             let (cache, sort_prefix) = Self::compute_properties(
                 &new_sort.input,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to