Skip to content

Commit

Permalink
[BUG] Fix Expr::with_new_children for ScalarFunction (#2624)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinzwang committed Aug 6, 2024
1 parent b0c9746 commit 94b4d38
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/daft-dsl/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,10 @@ impl Expr {
use Expr::*;
match self {
// no children
Column(..) | Literal(..) => self.clone(),
Column(..) | Literal(..) => {
assert!(children.is_empty(), "Should have no children");
self.clone()
}
// 1 child
Not(..) => Not(children.first().expect("Should have 1 child").clone()),
Alias(.., name) => Alias(
Expand Down Expand Up @@ -658,11 +661,30 @@ impl Expr {
},
// N-ary
Agg(agg_expr) => Agg(agg_expr.with_new_children(children)),
Function { func, .. } => Function {
func: func.clone(),
inputs: children,
},
ScalarFunction(sf) => ScalarFunction(sf.clone()),
Function {
func,
inputs: old_children,
} => {
assert!(
children.len() == old_children.len(),
"Should have same number of children"
);
Function {
func: func.clone(),
inputs: children,
}
}
ScalarFunction(sf) => {
assert!(
children.len() == sf.inputs.len(),
"Should have same number of children"
);

ScalarFunction(crate::functions::ScalarFunction {
udf: sf.udf.clone(),
inputs: children,
})
}
}
}

Expand Down

0 comments on commit 94b4d38

Please sign in to comment.