-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ES|QL: Initial grammar and changes for FORK (snapshot) #121948
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 43 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
e860a12
Grammar changes
ioanatia f0a64c8
Generate grammar changes
ioanatia 6398ece
Fork planning
ioanatia 3c66945
Fix field resolution
ioanatia af7ce2a
Cleanup
ioanatia d6b627c
Add CSV tests
ioanatia 7c557ec
Update docs/changelog/121948.yaml
ioanatia b19cb8c
[CI] Auto commit changes from spotless
3d652a4
fix forbidden apis
ChrisHegarty f944fde
Merge branch 'main' into fork
ChrisHegarty 4bfaaed
javadoc
ChrisHegarty ca7e8d0
remove serialization of fork and Merge
ChrisHegarty 41bcae9
fix equality
ChrisHegarty 94a33eb
fix EsqlNodeSubclassTests
ChrisHegarty 033a76a
add statement parser tests
ChrisHegarty f380d37
remove unnecessary serialization
ChrisHegarty aa74bfd
automatic fork branch ids start at 1
ChrisHegarty 31caf30
add analyzer test
ChrisHegarty e6fe497
more tests
ChrisHegarty 862f018
more tests
ChrisHegarty ed34a58
Merge branch 'main' into fork
ChrisHegarty b575a9c
minor itr
ChrisHegarty 51203bf
Merge branch 'main' into fork
ChrisHegarty 20c0a51
replace [] with ()
ChrisHegarty 90ebc7b
Merge branch 'main' into fork
ChrisHegarty f444947
move fork eval to initial logical plan
ChrisHegarty c064318
Merge branch 'main' into fork
ChrisHegarty a7a23b5
simplify MergeOperator finished state
ChrisHegarty 38c0577
enable CVS tests
ChrisHegarty 001e00c
rework Fork to use StubRelation and Merge to be Nary
ChrisHegarty 0e0ef78
reverts
ChrisHegarty 057381a
fail hard if not LocalSourceExec
ChrisHegarty a990ff3
spotless
ChrisHegarty 675ed14
Merge branch 'main' into fork
ChrisHegarty 85dfe2e
Merge branch 'main' into fork
ChrisHegarty 1a1aa80
no fork in fork yet
ChrisHegarty fb8f2e1
Merge branch 'main' into fork
ChrisHegarty f04dea5
Merge branch 'main' into fork
ChrisHegarty 9cde990
itr
ChrisHegarty da136b4
itr
ChrisHegarty 401c50d
itr
ChrisHegarty 9141739
fix EsqlNodeSubclassTests
ChrisHegarty 80ce2e7
Merge branch 'main' into fork
ChrisHegarty 96d00c2
more tests and restrict NESTED_XX to snapshot
ChrisHegarty cb4d29d
fix method name
ChrisHegarty 0d7e44b
Merge branch 'main' into fork
ChrisHegarty 5a14086
check for fork cap before testing ForkIT
ChrisHegarty e062fed
Merge branch 'main' into fork
ChrisHegarty 0e8e78d
Merge remote-tracking branch 'elasticsearch/main' into fork
ioanatia 2a1100a
Move fork id alias logic to parser
ioanatia 9d48ba0
Merge branch 'main' into fork
ioanatia 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: 121948 | ||
| summary: Add initial grammar and changes for FORK | ||
| area: ES|QL | ||
| type: feature | ||
| issues: [] |
85 changes: 85 additions & 0 deletions
85
...k/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/MergeOperator.java
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,85 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.compute.operator; | ||
|
|
||
| import org.elasticsearch.compute.data.Block; | ||
| import org.elasticsearch.compute.data.BlockFactory; | ||
| import org.elasticsearch.compute.data.Page; | ||
| import org.elasticsearch.core.Releasables; | ||
|
|
||
| import java.util.List; | ||
| import java.util.ListIterator; | ||
| import java.util.function.Supplier; | ||
|
|
||
| /** | ||
| * A merge operator is effectively a "fan-in" operator - accepts input | ||
| * from several sources and provides it in a single output. | ||
| */ | ||
| public class MergeOperator extends SourceOperator { | ||
|
|
||
| public record MergeOperatorFactory(BlockSuppliers suppliers) implements SourceOperatorFactory { | ||
| @Override | ||
| public String describe() { | ||
| return "MergeOperator[suppliers=" + suppliers + "]"; | ||
| } | ||
|
|
||
| @Override | ||
| public SourceOperator get(DriverContext driverContext) { | ||
| return new MergeOperator(driverContext.blockFactory(), suppliers); | ||
| } | ||
| } | ||
|
|
||
| private final BlockFactory blockFactory; | ||
| private final BlockSuppliers suppliers; | ||
| private boolean finished; | ||
| private ListIterator<Block[]> subPlanBlocks; | ||
|
|
||
| public MergeOperator(BlockFactory blockFactory, BlockSuppliers suppliers) { | ||
| super(); | ||
| this.blockFactory = blockFactory; | ||
| this.suppliers = suppliers; | ||
| } | ||
|
|
||
| public interface BlockSuppliers extends Supplier<List<Block[]>> {}; | ||
|
|
||
| @Override | ||
| public void finish() {} | ||
|
|
||
| @Override | ||
| public boolean isFinished() { | ||
| return finished; | ||
| } | ||
|
|
||
| @Override | ||
| public Page getOutput() { | ||
| if (subPlanBlocks == null) { | ||
| subPlanBlocks = suppliers.get().listIterator(); | ||
| } | ||
|
|
||
| if (subPlanBlocks.hasNext()) { | ||
| return new Page(subPlanBlocks.next()); | ||
| } | ||
| finished = true; | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public void close() { | ||
| // release blocks from any subplan not fully consumed. | ||
| if (subPlanBlocks != null) { | ||
| while (subPlanBlocks.hasNext()) { | ||
| Releasables.close(subPlanBlocks.next()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "MergeOperator[subPlanBlocks=" + subPlanBlocks + "]"; | ||
| } | ||
| } | ||
94 changes: 94 additions & 0 deletions
94
x-pack/plugin/esql/qa/testFixtures/src/main/resources/fork.csv-spec
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,94 @@ | ||
| // | ||
| // CSV spec for FORK command | ||
| // | ||
|
|
||
| simpleFork | ||
| required_capability: fork | ||
|
|
||
| FROM employees | ||
| | FORK ( WHERE emp_no == 10001 ) | ||
| ( WHERE emp_no == 10002 ) | ||
| | KEEP emp_no, _fork | ||
| | SORT emp_no | ||
| ; | ||
|
|
||
| emp_no:integer | _fork:keyword | ||
| 10001 | fork1 | ||
| 10002 | fork2 | ||
| ; | ||
|
|
||
| forkWithWhereSortAndLimit | ||
| required_capability: fork | ||
|
|
||
| FROM employees | ||
| | FORK ( WHERE hire_date < "1985-03-01T00:00:00Z" | SORT first_name | LIMIT 5 ) | ||
| ( WHERE hire_date < "1988-03-01T00:00:00Z" | SORT first_name | LIMIT 5 ) | ||
| | KEEP emp_no, first_name, _fork | ||
| | SORT emp_no, _fork | ||
| ; | ||
|
|
||
| emp_no:integer | first_name:keyword | _fork:keyword | ||
| 10002 | Bezalel | fork2 | ||
| 10009 | Sumant | fork1 | ||
| 10014 | Berni | fork2 | ||
| 10048 | Florian | fork1 | ||
| 10058 | Berhard | fork2 | ||
| 10060 | Breannda | fork2 | ||
| 10094 | Arumugam | fork2 | ||
| ; | ||
|
|
||
| fiveFork | ||
| required_capability: fork | ||
|
|
||
| FROM employees | ||
| | FORK ( WHERE emp_no == 10005 ) | ||
| ( WHERE emp_no == 10004 ) | ||
| ( WHERE emp_no == 10003 ) | ||
| ( WHERE emp_no == 10002 ) | ||
| ( WHERE emp_no == 10001 ) | ||
| | KEEP _fork, emp_no | ||
| | SORT _fork | ||
| ; | ||
|
|
||
| _fork:keyword | emp_no:integer | ||
| fork1 | 10005 | ||
| fork2 | 10004 | ||
| fork3 | 10003 | ||
| fork4 | 10002 | ||
| fork5 | 10001 | ||
| ; | ||
|
|
||
| forkWithWhereSortDescAndLimit | ||
| required_capability: fork | ||
|
|
||
| FROM employees | ||
| | FORK ( WHERE hire_date < "1985-03-01T00:00:00Z" | SORT first_name DESC | LIMIT 2 ) | ||
| ( WHERE hire_date < "1988-03-01T00:00:00Z" | SORT first_name DESC NULLS LAST | LIMIT 2 ) | ||
| | KEEP _fork, emp_no, first_name | ||
| | SORT _fork, first_name DESC | ||
| ; | ||
|
|
||
| _fork:keyword | emp_no:integer | first_name:keyword | ||
| fork1 | 10009 | Sumant | ||
| fork1 | 10048 | Florian | ||
| fork2 | 10081 | Zhongwei | ||
| fork2 | 10087 | Xinglin | ||
| ; | ||
|
|
||
| forkWithCommonPrefilter | ||
| required_capability: fork | ||
|
|
||
| FROM employees | ||
| | WHERE emp_no > 10050 | ||
| | FORK ( SORT emp_no ASC | LIMIT 2 ) | ||
| ( SORT emp_no DESC NULLS LAST | LIMIT 2 ) | ||
| | KEEP _fork, emp_no | ||
| | SORT _fork, emp_no | ||
| ; | ||
|
|
||
| _fork:keyword | emp_no:integer | ||
| fork1 | 10051 | ||
| fork1 | 10052 | ||
| fork2 | 10099 | ||
| fork2 | 10100 | ||
| ; |
Oops, something went wrong.
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.
This operator is somewhat temporary, until we stream the subquery results.