liningpan opened a new issue, #7004: URL: https://github.com/apache/arrow-datafusion/issues/7004
### Describe the bug The `simplify_expressions` optimizer incorrectly optimizes case expressions with a base expression and returns a boolean value. https://github.com/apache/arrow-datafusion/blob/b0d24912acd9d86ca6ce3af26b4d845ec250048d/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs#L1061-L1075 ### To Reproduce ```sql select case c1 when 'foo' then TRUE when 'bar' then FALSE end ``` Example test case can be added to `datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs` ```rust #[test] fn case_should_not_simplify() { simplify(simplify(Expr::Case(Case::new( Some(Box::new(col("c1"))), vec![ (Box::new(lit("foo")), Box::new(lit(true))), (Box::new(lit("bar")), Box::new(lit(false))), ], Some(Box::new(lit(true))), )))); } ``` Currently the test case panics on error `Internal("The type of Utf8 And Boolean of binary physical should be same")` ### Expected behavior The optimizer should not try to optimize this. ### Additional context _No response_ -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
