Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify EXPR LIKE 'constant' to expr = 'constant' #13192

Closed
alamb opened this issue Oct 30, 2024 · 3 comments
Closed

Simplify EXPR LIKE 'constant' to expr = 'constant' #13192

alamb opened this issue Oct 30, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented Oct 30, 2024

Is your feature request related to a problem or challenge?

As @adriangb observes in #12978, there is often special case handling for equality predicates like col = 'foo'

However, sometimes people (or tools) write queries using the LIKE operator:

SELECT ... WHERE col like 'foo'

Describe the solution you'd like

I think it would be nice if DataFusion's simplifier could simplify such expressions to WHERE col = 'foo', something that trino does (see trinodb/trino@6aea881#diff-3b166584d367d2e1bf2184249d6bad632bb4ecbe18e011f4744fdf629c771ce7R912)

> explain select * from values ('foo'), ('bar') where column1 like 'foo';
+---------------+---------------------------------------------+
| plan_type     | plan                                        |
+---------------+---------------------------------------------+
| logical_plan  | Filter: column1 LIKE Utf8("foo")            |
|               |   Values: (Utf8("foo")), (Utf8("bar"))      |
| physical_plan | CoalesceBatchesExec: target_batch_size=8192 |
|               |   FilterExec: column1@0 LIKE foo            |
|               |     ValuesExec                              |
|               |                                             |
+---------------+---------------------------------------------+
2 row(s) fetched.
Elapsed 0.006 seconds.

Describe alternatives you've considered

No response

Additional context

@adriangb has implemented a version of this here: #13061

@findepi
Copy link
Member

findepi commented Oct 31, 2024

@adriangb 's WIP: #13061

@ngli-me
Copy link
Contributor

ngli-me commented Feb 19, 2025

Hi! I'm just going through older issues, it looks like this one can be closed as of #13260, since #13061 got merged into that one?

@alamb
Copy link
Contributor Author

alamb commented Feb 19, 2025

Agreed -- thank you @ngli-me

@alamb alamb closed this as completed Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants