alamb commented on code in PR #4090:
URL: https://github.com/apache/arrow-datafusion/pull/4090#discussion_r1013390818
##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -365,6 +367,38 @@ impl<'a, S: SimplifyInfo> ExprRewriter for Simplifier<'a,
S> {
None => lit_bool_null(),
}
}
+ // expr IN () --> false
+ // expr NOT IN () --> true
+ Expr::InList {
+ expr,
+ list,
+ negated,
+ } if list.is_empty() && *expr != Expr::Literal(ScalarValue::Null)
=> {
+ lit(negated)
+ }
+
+ // if expr is a single column reference:
+ // expr IN (A, B, ...) --> (expr = A) OR (expr = B) OR (expr = C)
+ Expr::InList {
+ expr,
+ list,
+ negated,
+ } if list.len() == 1
Review Comment:
I agree documenting the rationale would be super helpful
--
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]