-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Change the order of the optimization rules #124335
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 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9828afc
Change the order of the optimization rules
astefan 8843569
Update docs/changelog/124335.yaml
astefan a2c33fa
[CI] Auto commit changes from spotless
18ebafe
Fix import
astefan 8beb022
Merge branch 'inlinestats_pickup3' of https://github.com/astefan/elas…
astefan 26f2349
More tests
astefan 68c31b7
Merge branch 'main' of https://github.com/elastic/elasticsearch into …
astefan 16311c2
[CI] Auto commit changes from spotless
a036535
Address reviews
astefan 89e76ef
Merge branch 'main' of https://github.com/elastic/elasticsearch into …
astefan eddde2d
update
astefan dc8c35d
Merge branch 'main' into inlinestats_pickup3
astefan ef8303c
Merge branch 'main' into inlinestats_pickup3
astefan 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 124335 | ||
| summary: Change the order of the optimization rules | ||
| area: ES|QL | ||
| type: bug | ||
| issues: [] |
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
258 changes: 236 additions & 22 deletions
258
x-pack/plugin/esql/qa/testFixtures/src/main/resources/inlinestats.csv-spec
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
|---|---|---|
|
|
@@ -34,7 +34,6 @@ protected LogicalPlan rule(InlineJoin plan) { | |
| // check if there's any grouping that uses a reference on the right side | ||
|
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. Only a small cleanup here. |
||
| // if so, look for the source until finding a StubReference | ||
| // then copy those on the left side as well | ||
|
|
||
| LogicalPlan left = plan.left(); | ||
| LogicalPlan right = plan.right(); | ||
|
|
||
|
|
@@ -46,7 +45,6 @@ protected LogicalPlan rule(InlineJoin plan) { | |
| // first checks any aggregate that declares expressions inside the grouping | ||
| // second that checks any found references to collect their declaration | ||
| right = right.transformDown(p -> { | ||
|
|
||
| if (p instanceof Aggregate aggregate) { | ||
| // collect references | ||
| for (Expression g : aggregate.groupings()) { | ||
|
|
@@ -56,6 +54,10 @@ protected LogicalPlan rule(InlineJoin plan) { | |
| } | ||
| } | ||
|
|
||
| if (groupingRefs.isEmpty()) { | ||
alex-spies marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return p; | ||
| } | ||
|
|
||
| // find their declaration and remove it | ||
| // TODO: this doesn't take into account aliasing | ||
|
||
| if (p instanceof Eval eval) { | ||
alex-spies marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
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 just realized that it's probably a good idea to add tests for
INLINESTATS ... BY x = bucket(...)andINLINESTATS ... BY x = CATEGORIZE(...). I think the latter cannot work because the join key inBY x = CATEGORIZE(...)is computed during the aggregation, whereasINLINESTATSrequires the join key to be present before that.Cc @jan-elastic , I think we'll have to start out with a limitation where
INLINESTATScan't useCATEGORIZE, at least at first; to enable this, I think we'd somehow have to grab the categorizer from the first phase of the query (which computes the STATS) and make it available to the second phase of the query (which performs the joining with every row we see).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.
FWIW, I can live with the fact that the first version of INLINESTATS doesn't work with CATEGORIZE.
Just open a GitHub issue for that and it can be resolved 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 opened #124717