This is an automated email from the ASF dual-hosted git repository.

viirya pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion-comet.git


The following commit(s) were added to refs/heads/main by this push:
     new 51a0b0b  fix: Fix wrong children expression order in IfExpr (#249)
51a0b0b is described below

commit 51a0b0b2f4fc0dd3f8a711624b97d1170bfd43ab
Author: Liang-Chi Hsieh <[email protected]>
AuthorDate: Tue Apr 9 09:08:24 2024 -0700

    fix: Fix wrong children expression order in IfExpr (#249)
---
 core/src/execution/datafusion/expressions/if_expr.rs | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/core/src/execution/datafusion/expressions/if_expr.rs 
b/core/src/execution/datafusion/expressions/if_expr.rs
index 826f017..6f2ed6a 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<Arc<dyn PhysicalExpr>> {
         vec![
-            self.true_expr.clone(),
             self.if_expr.clone(),
+            self.true_expr.clone(),
             self.false_expr.clone(),
         ]
     }
@@ -218,4 +218,18 @@ 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");
+        assert_eq!(children[1].to_string(), "123");
+        assert_eq!(children[2].to_string(), "999");
+    }
 }

Reply via email to