sdf-jkl commented on code in PR #20051:
URL: https://github.com/apache/datafusion/pull/20051#discussion_r2744001653
##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -2038,6 +2038,52 @@ impl TreeNodeRewriter for Simplifier<'_> {
Transformed::no(Expr::BinaryExpr(BinaryExpr { left, op,
right }))
}
}
+ // For case:
+ // date_part('YEAR', expr) IN (literal1, literal2, ...)
+ Expr::InList(InList { expr, list, negated }) => {
+ if list.len() > THRESHOLD_INLINE_INLIST ||
list.iter().any(is_null) {
+ return Ok(Transformed::no(Expr::InList(InList {
+ expr,
+ list,
+ negated,
+ })));
+ }
+
+ let mut rewritten: Option<Expr> = None;
+ for item in &list {
+ let PreimageResult::Range { interval, expr } =
+ get_preimage(expr.as_ref(), item, info)?
+ else {
+ return Ok(Transformed::no(Expr::InList(InList {
+ expr,
+ list,
+ negated,
+ })));
+ };
+
+ let (op, combiner): (Operator, fn(Expr, Expr) -> Expr) =
if negated {
+ (NotEq, and)
+ } else {
+ (Eq, or)
+ };
Review Comment:
Fixed
https://github.com/apache/datafusion/pull/20051/commits/0f2e8ecf4630e73958f48440ca124fcc09ae52d1
--
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]