findepi commented on code in PR #13061:
URL: https://github.com/apache/datafusion/pull/13061#discussion_r1824100046
##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -1446,18 +1446,54 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for
Simplifier<'a, S> {
// Rules for Like
Expr::Like(Like {
- expr,
- pattern,
+ expr: ref like_expr,
+ ref pattern, // Changed to ref pattern to avoid moving
negated,
- escape_char: _,
- case_insensitive: _,
- }) if !is_null(&expr)
- && matches!(
- pattern.as_ref(),
- Expr::Literal(ScalarValue::Utf8(Some(pattern_str))) if
pattern_str == "%"
- ) =>
- {
- Transformed::yes(lit(!negated))
+ escape_char,
+ case_insensitive,
+ }) => {
+ if let Expr::Literal(ScalarValue::Utf8(Some(pattern))) =
pattern.as_ref()
+ {
+ // Special case: pattern is just "%"
+ if pattern == "%" && !is_null(like_expr) {
+ return Ok(Transformed::yes(lit(!negated)));
Review Comment:
See also
https://github.com/apache/datafusion/issues/12637#issuecomment-2449352017
--
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]