jackye1995 opened a new pull request, #21086:
URL: https://github.com/apache/datafusion/pull/21086
## Summary
The `starts_with` simplification escapes special LIKE characters (`%`, `_`,
`\`) with backslash but did not set `escape_char` in the resulting LIKE
expression. This caused the escaped characters to be treated as literals
instead of escape sequences.
## Problem
When `starts_with(col, 'test_ns')` is simplified to `col LIKE 'test\_ns%'`,
the `escape_char` was set to `None`. This meant the `\_` was not recognized as
an escaped underscore, and the underscore was incorrectly interpreted as a LIKE
wildcard matching any single character.
### Example
```sql
-- Input
starts_with(namespace, 'test_ns$')
-- Before fix (incorrect)
namespace LIKE 'test\_ns$%' -- escape_char: None
-- The `_` is treated as wildcard, matching any char
-- After fix (correct)
namespace LIKE 'test\_ns$%' -- escape_char: Some('\\')
-- The `\_` is correctly interpreted as literal underscore
```
## Fix
Set `escape_char: Some('\\')` when creating the LIKE expression, since the
simplification already uses backslash to escape special characters.
## Testing
- Existing `starts_with` tests pass
- Verified fix resolves query correctness issues in downstream projects
(Lance)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]