You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "allenma (via GitHub)" <gi...@apache.org> on 2023/04/07 09:29:11 UTC

[GitHub] [arrow-datafusion] allenma opened a new pull request, #5911: Add if function support

allenma opened a new pull request, #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #5910.
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   Most of the sql engines support if function, like spark, snowflake, mysql, etc. It is similar as Case expression, but only support one condition, that make user easier to use this function for simple cases, and easier to migrate from the existing system.
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   Add 'If' build in function, the function syntax is like:
   IF( <condition> , <expr1> , <expr2> )
   If condition evaluates to TRUE, returns expr1, otherwise returns expr2
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   Yes, new UT added.
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   No
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5911: Add if function support

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1502353789

   This PR appears to have accumulated some conflicts with the `main` branch as wel


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] viirya commented on a diff in pull request #5911: Add if function support

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#discussion_r1160843605


##########
datafusion/physical-expr/src/expressions/if_fun.rs:
##########
@@ -0,0 +1,175 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::array::{Array, ArrayRef};
+use arrow::compute::kernels::zip::zip;
+use datafusion_common::{cast::as_boolean_array, DataFusionError, Result, ScalarValue};
+use datafusion_expr::ColumnarValue;
+
+/// Implements IF(expr1, expr2, expr3)
+/// If `expr1` evaluates to true, then returns `expr2`; otherwise returns `expr3`.
+/// Args: 0 - boolean array
+///       1 - if expr1 is true, then the result is expr2
+///       2 - if expr1 is true, then the result is expr3.
+///
+pub fn if_func(args: &[ColumnarValue]) -> Result<ColumnarValue> {
+    if args.len() != 3 {
+        return Err(DataFusionError::Internal(format!(
+            "{:?} args were supplied but IF takes exactly 3 args",
+            args.len(),
+        )));
+    }
+    let mut array_lens = args.iter().filter_map(|x| match x {
+        ColumnarValue::Array(array) => Some(array.len()),
+        _ => None,
+    });
+
+    let (predicates, true_vals, false_vals) = (&args[0], &args[1], &args[2]);
+
+    if let Some(size) = array_lens.next() {
+        match predicates {
+            ColumnarValue::Scalar(_) => {
+                handle_scalar_predicates(predicates, true_vals, false_vals)
+            }
+            ColumnarValue::Array(predicates) => {
+                handle_array_predicates(predicates, size, true_vals, false_vals)
+            }
+        }
+    } else {
+        handle_scalar_predicates(predicates, true_vals, false_vals)
+    }
+}
+
+fn handle_scalar_predicates(
+    predicates: &ColumnarValue,
+    true_vals: &ColumnarValue,
+    false_vals: &ColumnarValue,
+) -> Result<ColumnarValue> {
+    match predicates {
+        ColumnarValue::Scalar(ScalarValue::Boolean(Some(predicates))) => {
+            if *predicates {
+                Ok(true_vals.clone())
+            } else {
+                Ok(false_vals.clone())
+            }
+        }
+        ColumnarValue::Scalar(val) if val.is_null() => Ok(false_vals.clone()),

Review Comment:
   Shouldn't we check the datatype of `val`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5911: Add if function support

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1508920503

   @allenma  can you please resolve the conflicts and when you have done so mark this PR as ready to review again? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] viirya commented on a diff in pull request #5911: Add if function support

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on code in PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#discussion_r1160840881


##########
datafusion/physical-expr/src/expressions/if_fun.rs:
##########
@@ -0,0 +1,175 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::array::{Array, ArrayRef};
+use arrow::compute::kernels::zip::zip;
+use datafusion_common::{cast::as_boolean_array, DataFusionError, Result, ScalarValue};
+use datafusion_expr::ColumnarValue;
+
+/// Implements IF(expr1, expr2, expr3)
+/// If `expr1` evaluates to true, then returns `expr2`; otherwise returns `expr3`.
+/// Args: 0 - boolean array
+///       1 - if expr1 is true, then the result is expr2
+///       2 - if expr1 is true, then the result is expr3.

Review Comment:
   ```suggestion
   ///       2 - if expr1 is false, then the result is expr3.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] allenma commented on a diff in pull request #5911: Add if function support

Posted by "allenma (via GitHub)" <gi...@apache.org>.
allenma commented on code in PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#discussion_r1161053425


##########
datafusion/physical-expr/src/expressions/if_fun.rs:
##########
@@ -0,0 +1,175 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::array::{Array, ArrayRef};
+use arrow::compute::kernels::zip::zip;
+use datafusion_common::{cast::as_boolean_array, DataFusionError, Result, ScalarValue};
+use datafusion_expr::ColumnarValue;
+
+/// Implements IF(expr1, expr2, expr3)
+/// If `expr1` evaluates to true, then returns `expr2`; otherwise returns `expr3`.
+/// Args: 0 - boolean array
+///       1 - if expr1 is true, then the result is expr2
+///       2 - if expr1 is true, then the result is expr3.
+///
+pub fn if_func(args: &[ColumnarValue]) -> Result<ColumnarValue> {
+    if args.len() != 3 {
+        return Err(DataFusionError::Internal(format!(
+            "{:?} args were supplied but IF takes exactly 3 args",
+            args.len(),
+        )));
+    }
+    let mut array_lens = args.iter().filter_map(|x| match x {
+        ColumnarValue::Array(array) => Some(array.len()),
+        _ => None,
+    });
+
+    let (predicates, true_vals, false_vals) = (&args[0], &args[1], &args[2]);
+
+    if let Some(size) = array_lens.next() {
+        match predicates {
+            ColumnarValue::Scalar(_) => {
+                handle_scalar_predicates(predicates, true_vals, false_vals)
+            }
+            ColumnarValue::Array(predicates) => {
+                handle_array_predicates(predicates, size, true_vals, false_vals)
+            }
+        }
+    } else {
+        handle_scalar_predicates(predicates, true_vals, false_vals)
+    }
+}
+
+fn handle_scalar_predicates(
+    predicates: &ColumnarValue,
+    true_vals: &ColumnarValue,
+    false_vals: &ColumnarValue,
+) -> Result<ColumnarValue> {
+    match predicates {
+        ColumnarValue::Scalar(ScalarValue::Boolean(Some(predicates))) => {
+            if *predicates {
+                Ok(true_vals.clone())
+            } else {
+                Ok(false_vals.clone())
+            }
+        }
+        ColumnarValue::Scalar(val) if val.is_null() => Ok(false_vals.clone()),

Review Comment:
   Hi @viirya ,here I just want to handle when the predicate expression is constant null,  then return the false values, like function: if(null, 1, 2) will return 2.
   null values for any data type can be considered as false, and I just add is_null check for the val, I think no need to check the datatype



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] yjshen commented on pull request #5911: Add if function support

Posted by "yjshen (via GitHub)" <gi...@apache.org>.
yjshen commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1520493026

   > What is the status of this PR? It seems to have a few conflicts and maybe waiting on some final touchups, but otherwise is it ready to go ?
   
   @alamb I suggested putting the `IF` expr to `CASE WHEN` expr conversion as an analyzer rule before type coercion so that the operand for `IF` could be correctly type coerced. I think @allenma is trying this way out.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] allenma commented on pull request #5911: Add if function support

Posted by "allenma (via GitHub)" <gi...@apache.org>.
allenma commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1510859945

   @yjshen @yahoNanJing , change code to make the if function as syntax sugar of case expr 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] allenma commented on pull request #5911: Add if function support

Posted by "allenma (via GitHub)" <gi...@apache.org>.
allenma commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1510648558

   Rebase the latest code to resolve code conflict


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5911: Add if function support

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1525882645

   > Hi @alamb , I'm busy with other things, so don't have much time to refactor as @yjshen suggest, could you mark this pr as draft, I can pick up when I have time.
   
   
   
   Done -- thank you @allenma 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] allenma commented on pull request #5911: Add if function support

Posted by "allenma (via GitHub)" <gi...@apache.org>.
allenma commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1521501978

   Hi @alamb , I'm busy with other things, so don't have much time to refactor as @yjshen suggest, could you mark this pr as draft, I can pick up when I have time.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add if function support [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-2043645171

   Since this has been open for more than a year, closing it down. Feel free to reopen if/when you keep working on it. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] yahoNanJing commented on pull request #5911: Add if function support

Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1501439979

   @yjshen, could you help check this PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] yjshen commented on pull request #5911: Add if function support

Posted by "yjshen (via GitHub)" <gi...@apache.org>.
yjshen commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1501536412

   Hi @allenma! Thanks for the contribution! ❤️ 
   
   Several thoughts from my side:
   1. What do you think if we make `If` a new expr type? Expr might be more flexible than the built-in function so that we could achieve some short-circuit optimizations. (We could avoid evaluating the whole false_val array if the condition boolean array is mostly true)
   2. What do you think if we make the `if` expression a syntax sugar for the `case when` and rewrite it during the analyzer? We could easily have both short-circuit and type-coercion for `if`. Is there something special case that is not handled by `case when` or something else I'm not aware of?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add if function support [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed pull request #5911: Add if function support
URL: https://github.com/apache/arrow-datafusion/pull/5911


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5911: Add if function support

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1520335789

   What is the status of this PR? It seems to have a few conflicts and maybe waiting on some final touchups, but otherwise is it ready to go ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] allenma commented on pull request #5911: Add if function support

Posted by "allenma (via GitHub)" <gi...@apache.org>.
allenma commented on PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#issuecomment-1501758241

   Thanks @yjshen for your good suggestion, actually I thought before that implement the if function as syntax sugar of case when, but during implementation I found it is not easy do it in the logical plan -> physical plan phase, and need to do conversion in the syntax tree to logical plan phase, and implement it as build-in function is pretty straightforward.
   Anyway let me revisit the code again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] allenma commented on a diff in pull request #5911: Add if function support

Posted by "allenma (via GitHub)" <gi...@apache.org>.
allenma commented on code in PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#discussion_r1168498023


##########
datafusion/physical-expr/src/functions.rs:
##########
@@ -64,6 +65,22 @@ pub fn create_physical_expr(
 
     let data_type = function::return_type(fun, &input_expr_types)?;
 
+    // if function will be converted to case expression
+    if let BuiltinScalarFunction::If = fun {
+        if input_phy_exprs.len() != 3 {
+            return Err(DataFusionError::Internal(format!(
+                "{:?} args were supplied but IF function takes exactly 3 args",
+                input_phy_exprs.len(),
+            )));
+        }
+        let (when_expr, then_expr, else_expr) = (
+            Arc::clone(&input_phy_exprs[0]),
+            Arc::clone(&input_phy_exprs[1]),
+            Arc::clone(&input_phy_exprs[2]),
+        );
+        return case(None, vec![(when_expr, then_expr)], Some(else_expr));

Review Comment:
   Good idea, let me check how to do it:)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] yjshen commented on a diff in pull request #5911: Add if function support

Posted by "yjshen (via GitHub)" <gi...@apache.org>.
yjshen commented on code in PR #5911:
URL: https://github.com/apache/arrow-datafusion/pull/5911#discussion_r1168344133


##########
datafusion/physical-expr/src/functions.rs:
##########
@@ -64,6 +65,22 @@ pub fn create_physical_expr(
 
     let data_type = function::return_type(fun, &input_expr_types)?;
 
+    // if function will be converted to case expression
+    if let BuiltinScalarFunction::If = fun {
+        if input_phy_exprs.len() != 3 {
+            return Err(DataFusionError::Internal(format!(
+                "{:?} args were supplied but IF function takes exactly 3 args",
+                input_phy_exprs.len(),
+            )));
+        }
+        let (when_expr, then_expr, else_expr) = (
+            Arc::clone(&input_phy_exprs[0]),
+            Arc::clone(&input_phy_exprs[1]),
+            Arc::clone(&input_phy_exprs[2]),
+        );
+        return case(None, vec![(when_expr, then_expr)], Some(else_expr));

Review Comment:
   I would like to transfer the conversion code from its current location (where the physical expression was created) to a new analyzer rule. The new rule should happen before the `TypeCoercion` rule so that `expr[1]`, `expr[2]` can be correctly type coerced; by doing this, your test against Int32 and Int64 could be cast into common types. Cc @jackwener for expert opinion.
   
   For example:
   ```rust
   impl Analyzer {
       /// Create a new analyzer using the recommended list of rules
       pub fn new() -> Self {
           let rules: Vec<Arc<dyn AnalyzerRule + Send + Sync>> = vec![
               Arc::new(InlineTableScan::new()),
               Arc::new(RewriteIfExpr::new()), // rule that rewrite if expr
               Arc::new(TypeCoercion::new()),
               Arc::new(CountWildcardRule::new()),
           ];
           Self::with_rules(rules)
       }
   ```



##########
datafusion/core/tests/sql/functions.rs:
##########
@@ -565,3 +565,119 @@ async fn test_power() -> Result<()> {
 
     Ok(())
 }
+
+#[tokio::test]
+async fn if_static_value() -> Result<()> {
+    let ctx = SessionContext::new();
+    let sql = "SELECT IF(true, 1, 2)";
+    let actual = execute_to_batches(&ctx, sql).await;
+    let expected = vec![
+        "+-------------------------------------+",
+        "| if(Boolean(true),Int64(1),Int64(2)) |",
+        "+-------------------------------------+",
+        "| 1                                   |",
+        "+-------------------------------------+",
+    ];
+    assert_batches_eq!(expected, &actual);
+
+    let sql = "SELECT IF(false, 1, 2)";
+    let actual = execute_to_batches(&ctx, sql).await;
+    let expected = vec![
+        "+--------------------------------------+",
+        "| if(Boolean(false),Int64(1),Int64(2)) |",
+        "+--------------------------------------+",
+        "| 2                                    |",
+        "+--------------------------------------+",
+    ];
+    assert_batches_eq!(expected, &actual);
+
+    let sql = "SELECT IF(1 = 2, 1 + 5, 2 + 4)";

Review Comment:
   Shall we make it `1+4` and `2+4`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org