Skip to content

Commit

Permalink
fix: have orderings include constants which are heterogenius across p…
Browse files Browse the repository at this point in the history
…artitions
  • Loading branch information
wiedld committed Feb 26, 2025
1 parent dffeaac commit 5a4ef63
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions datafusion/physical-expr/src/equivalence/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ pub fn const_exprs_contains(
const_exprs: &[ConstExpr],
expr: &Arc<dyn PhysicalExpr>,
) -> bool {
const_exprs
.iter()
.any(|const_expr| const_expr.expr.eq(expr))
const_exprs.iter().any(|const_expr| {
const_expr.expr.eq(expr)
&& const_expr.across_partitions() != AcrossPartitions::Heterogeneous
})
}

/// An `EquivalenceClass` is a set of [`Arc<dyn PhysicalExpr>`]s that are known
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/equivalence/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl EquivalenceProperties {
let filtered_exprs = LexOrdering::new(
sort_exprs
.into_iter()
.filter(|expr| !self.is_expr_constant(&expr.expr))
.filter(|expr| !self.is_expr_constant_across_partitions(&expr.expr))
.collect(),
);

Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-optimizer/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn add_sort_above<T: Clone + Default>(
!node
.plan
.equivalence_properties()
.is_expr_constant(&sort_expr.expr)
.is_expr_constant_across_partitions(&sort_expr.expr)
});
let mut new_sort = SortExec::new(sort_expr, Arc::clone(&node.plan)).with_fetch(fetch);
if node.plan.output_partitioning().partition_count() > 1 {
Expand Down

0 comments on commit 5a4ef63

Please sign in to comment.