From df603dd4725b4157944fd72709d0f28832c1eada Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Mon, 8 Apr 2024 22:33:25 -0700 Subject: [PATCH] fix: Fix wrong children expression order in IfExpr --- .../execution/datafusion/expressions/if_expr.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/execution/datafusion/expressions/if_expr.rs b/core/src/execution/datafusion/expressions/if_expr.rs index 826f017c12..0af079c307 100644 --- a/core/src/execution/datafusion/expressions/if_expr.rs +++ b/core/src/execution/datafusion/expressions/if_expr.rs @@ -112,8 +112,8 @@ impl PhysicalExpr for IfExpr { fn children(&self) -> Vec> { vec![ - self.true_expr.clone(), self.if_expr.clone(), + self.true_expr.clone(), self.false_expr.clone(), ] } @@ -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"); + } }