liukun4515 commented on issue #8927: URL: https://github.com/apache/datafusion/issues/8927#issuecomment-2105525720
> I also find some very special cases when I meet the error. This is example sql: > > ``` > SELECT > ( > case > when SUM(col1) != 0 then SUM(col1) / SUM(col2) > else 0 > end > ) as metric > FROM > table > having > ( > metric > 0 > ) > ``` > > This a case when case, but the filter `metric > 0` will changed to `and` filter in the `simplify_expressions` optimization rule In the `simplify_expressions` rule, we convert the `CASE WHEN` to filter but ignore the corner case. The above plan will get the filter plan like: ``` filter: SUM(col1) != 0 and SUM(col1) / SUM(col2) > 0 ``` Due to the bug: the behavior of And and Or operation is wrong https://github.com/apache/arrow-datafusion/blob/b7e13a0af711477ad41450566c14430089edd3f2/datafusion/physical-expr/src/expressions/binary.rs#L262-L263 We will get error in the runtime. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
