Skip to content

Commit

Permalink
fix: Fix wrong children expression order in IfExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Apr 9, 2024
1 parent 59f535c commit df603dd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/src/execution/datafusion/expressions/if_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ impl PhysicalExpr for IfExpr {

fn children(&self) -> Vec<Arc<dyn PhysicalExpr>> {
vec![
self.true_expr.clone(),
self.if_expr.clone(),
self.true_expr.clone(),
self.false_expr.clone(),
]
}
Expand Down Expand Up @@ -218,4 +218,16 @@ mod tests {

Ok(())
}

#[test]
fn test_if_children() {
let if_expr = lit(true);
let true_expr = lit(123i32);
let false_expr = lit(999i32);

let expr = if_fn(if_expr, true_expr, false_expr);
let children = expr.unwrap().children();
assert_eq!(children.len(), 3);
assert_eq!(children[0].to_string(), "true");
}
}

0 comments on commit df603dd

Please sign in to comment.