Skip to content

Commit ed0a060

Browse files
authored
replace private is_volatile_expression_tree with equivalent public is_volatile (#20056)
Reduces LOC and duplication. Public version is more efficient (stops recursion early).
1 parent 41bfb79 commit ed0a060

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

datafusion/physical-optimizer/src/projection_pushdown.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use datafusion_common::tree_node::{
3232
};
3333
use datafusion_common::{JoinSide, JoinType, Result};
3434
use datafusion_physical_expr::expressions::Column;
35-
use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
35+
use datafusion_physical_expr_common::physical_expr::{PhysicalExpr, is_volatile};
3636
use datafusion_physical_plan::ExecutionPlan;
3737
use datafusion_physical_plan::joins::NestedLoopJoinExec;
3838
use datafusion_physical_plan::joins::utils::{ColumnIndex, JoinFilter};
@@ -349,8 +349,7 @@ impl<'a> JoinFilterRewriter<'a> {
349349
// Recurse if there is a dependency to both sides or if the entire expression is volatile.
350350
let depends_on_other_side =
351351
self.depends_on_join_side(&expr, self.join_side.negate())?;
352-
let is_volatile = is_volatile_expression_tree(expr.as_ref());
353-
if depends_on_other_side || is_volatile {
352+
if depends_on_other_side || is_volatile(&expr) {
354353
return expr.map_children(|expr| self.rewrite(expr));
355354
}
356355

@@ -431,18 +430,6 @@ impl<'a> JoinFilterRewriter<'a> {
431430
}
432431
}
433432

434-
fn is_volatile_expression_tree(expr: &dyn PhysicalExpr) -> bool {
435-
if expr.is_volatile_node() {
436-
return true;
437-
}
438-
439-
expr.children()
440-
.iter()
441-
.map(|expr| is_volatile_expression_tree(expr.as_ref()))
442-
.reduce(|lhs, rhs| lhs || rhs)
443-
.unwrap_or(false)
444-
}
445-
446433
#[cfg(test)]
447434
mod test {
448435
use super::*;

0 commit comments

Comments
 (0)