ESQL: Begin optimizing Block#lookup#108482
Merged
nik9000 merged 3 commits intoelastic:mainfrom May 10, 2024
Merged
Conversation
This creates the infrastructure to allow optimizing the `lookup` method when applied to `Vector`s and then implements that optimization for constant vectors. Constant vectors now take one of six paths: 1. An empty positions `Block` yields an empty result set. 2. If `positions` is a `Block`, perform the un-optimized lookup. 3. If the `min` of the `positions` *Vector* is less that 0 then throw an exception. 4. If the `min` of the positions Vector is greater than the number of positions in the lookup block then return a single `ConstantNullBlock` because you are looking up outside the range. 5. If the `max` of the positions Vector is less than the number of positions in the lookup block then return a `Constant$Type$Block` with the same value as the lookup block. This is a lookup that's entirely within range. 6. Otherwise return the unoptimized lookup. This is *fairly* simple but demonstrates how we can plug in more complex optimizations later.
Collaborator
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
rjernst
approved these changes
May 9, 2024
Member
rjernst
left a comment
There was a problem hiding this comment.
Core lib change looks good to me, one small suggestion.
|
|
||
| @Override | ||
| public T next() { | ||
| return null; |
Member
There was a problem hiding this comment.
We could assert false here? next should never be called in this case
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jun 7, 2024
This adds support for `LOOKUP`, a command that implements a sort of
inline `ENRICH`, using data that is passed in the request:
```
$ curl -uelastic:password -HContent-Type:application/json -XPOST \
'localhost:9200/_query?error_trace&pretty&format=txt' \
-d'{
"query": "ROW a=1::LONG | LOOKUP t ON a",
"tables": {
"t": {
"a:long": [ 1, 4, 2],
"v1:integer": [ 10, 11, 12],
"v2:keyword": ["cat", "dog", "wow"]
}
},
"version": "2024.04.01"
}'
v1 | v2 | a
---------------+---------------+---------------
10 |cat |1
```
This required these PRs: * #107624 * #107634 * #107701 * #107762 *
#107923 * #107894 * #107982 * #108012 * #108020 * #108169 * #108191 *
#108334 * #108482 * #108696 * #109040 * #109045
Closes #107306
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This creates the infrastructure to allow optimizing the
lookupmethod when applied toVectors and then implements that optimization for constant vectors. Constant vectors now take one of six paths:Blockyields an empty result set.positionsis aBlock, perform the un-optimized lookup.minof thepositionsVector is less that 0 then throw an exception.minof the positions Vector is greater than the number of positions in the lookup block then return a singleConstantNullBlockbecause you are looking up outside the range.maxof the positions Vector is less than the number of positions in the lookup block then return aConstant$Type$Blockwith the same value as the lookup block. This is a lookup that's entirely within range.This is fairly simple but demonstrates how we can plug in more complex optimizations later.