xumingming opened a new pull request, #60054:
URL: https://github.com/apache/spark/pull/60054
### What changes were proposed in this pull request?
- Restrict `LikeSimplification`, including the multi-LIKE paths that funnel
through it, to string types with binary equality.
- Use the byte-length guard now that non-binary inputs no longer reach the
rewrite.
- Add plan-level and end-to-end regression tests for UTF8_LCASE, all
simplifiable LIKE shapes, multi-LIKE, and a UTF8_BINARY positive control.
### Why are the changes needed?
Under UTF8_LCASE, `LIKE` uses Java regex case folding, while the replacement
predicates use ICU lowercase mapping. These disagree for some code points, so
simplification can change query results. For example, `LIKE(COLLATE('ı',
'UTF8_LCASE'), '%i%')` evaluates to true before optimization but evaluated to
false after being rewritten to `Contains`.
### Does this PR introduce _any_ user-facing change?
Yes. `LIKE` predicates on non-binary collations are no longer simplified,
preserving the original matching semantics. The dotless-i example above now
remains true after optimization. Binary-collation predicates continue to be
simplified as before.
### How was this patch tested?
Added regression coverage to `LikeSimplificationSuite` and
`CollationSQLRegexpSuite`.
Ran:
```
build/sbt 'catalyst/testOnly
org.apache.spark.sql.catalyst.optimizer.LikeSimplificationSuite' 'sql/testOnly
org.apache.spark.sql.collation.CollationSQLRegexpSuite'
build/sbt 'catalyst/Test/compile' 'catalyst/Test/scalastyle'
```
`LikeSimplificationSuite` passed 26/26 tests, `CollationSQLRegexpSuite`
passed 20/20 tests, and test scalastyle reported no errors or warnings.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Pi
--
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]