-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Enhance: simplify x=x --> x IS NOT NULL OR NULL
#15589
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6130,7 +6130,8 @@ select count(*) from test WHERE array_has([needle], needle); | |
| ---- | ||
| 100000 | ||
|
|
||
| # TODO: this should probably be possible to completely remove the filter as always true? | ||
| # The optimizer does not currently eliminate the filter; | ||
| # Instead, it's rewritten as `IS NULL OR NOT NULL` due to SQL null semantics | ||
| query TT | ||
| explain with test AS (SELECT substr(md5(i::text)::text, 1, 32) as needle FROM generate_series(1, 100000) t(i)) | ||
| select count(*) from test WHERE array_has([needle], needle); | ||
|
|
@@ -6140,21 +6141,19 @@ logical_plan | |
| 02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] | ||
| 03)----SubqueryAlias: test | ||
| 04)------SubqueryAlias: t | ||
| 05)--------Projection: | ||
| 06)----------Filter: __common_expr_3 = __common_expr_3 | ||
| 07)------------Projection: substr(CAST(md5(CAST(tmp_table.value AS Utf8)) AS Utf8), Int64(1), Int64(32)) AS __common_expr_3 | ||
| 08)--------------TableScan: tmp_table projection=[value] | ||
| 05)--------Projection: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a comment a few lines above that says:
We can probably update that too -- but we could do it in a follow on PR as well |
||
| 06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8)) AS Utf8), Int64(1), Int64(32)) IS NOT NULL OR Boolean(NULL) | ||
| 07)------------TableScan: tmp_table projection=[value] | ||
| physical_plan | ||
| 01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)] | ||
| 02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))] | ||
| 03)----CoalescePartitionsExec | ||
| 04)------AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))] | ||
| 05)--------ProjectionExec: expr=[] | ||
| 06)----------CoalesceBatchesExec: target_batch_size=8192 | ||
| 07)------------FilterExec: __common_expr_3@0 = __common_expr_3@0 | ||
| 08)--------------ProjectionExec: expr=[substr(md5(CAST(value@0 AS Utf8)), 1, 32) as __common_expr_3] | ||
| 09)----------------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1 | ||
| 10)------------------LazyMemoryExec: partitions=1, batch_generators=[generate_series: start=1, end=100000, batch_size=8192] | ||
| 07)------------FilterExec: substr(md5(CAST(value@0 AS Utf8)), 1, 32) IS NOT NULL OR NULL | ||
| 08)--------------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1 | ||
| 09)----------------LazyMemoryExec: partitions=1, batch_generators=[generate_series: start=1, end=100000, batch_size=8192] | ||
|
|
||
| # any operator | ||
| query ? | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the comment in slt as well :)