Skip to content

ESQL: Add Block#lookup method#107982

Merged
nik9000 merged 1 commit intoelastic:mainfrom
nik9000:block_lookup
Apr 28, 2024
Merged

ESQL: Add Block#lookup method#107982
nik9000 merged 1 commit intoelastic:mainfrom
nik9000:block_lookup

Conversation

@nik9000
Copy link
Copy Markdown
Member

@nik9000 nik9000 commented Apr 27, 2024

This adds a method to build a new Block by looking up the values in an existing Block. Like BlockHash#lookup this returns a ReleasableIterator. This should allow us to load values using the results of BlockHash#lookup.

This adds a method to build a new `Block` by looking up the values in an
existing `Block`. Like `BlockHash#lookup` this returns a
`ReleasableIterator`. This should allow us to load values using the
results of `BlockHash#lookup`.
@nik9000 nik9000 requested a review from dnhatn April 27, 2024 23:07
@nik9000 nik9000 requested a review from a team as a code owner April 27, 2024 23:07
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Apr 27, 2024
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

Copy link
Copy Markdown
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, but looks great. Thanks Nik!

* same number of {@link #getPositionCount() positions} as the {@code positions}
* parameter.
* <p>
* For example, this this block contained {@code [a, b, [b, c]]}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this javadoc.

$Type$Block filter(int... positions);

@Override
ReleasableIterator<? extends $Type$Block> lookup(IntBlock positions, ByteSizeValue targetBlockSize);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make it as a default method, overrides subclasses where we can have optimizations?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it and decided against it because:

  1. I thought it'd be weird to stick it here - on X-Block instead of on Block. If it were on Block that'd be normal and good and easy. But putting it here feels a bit sneaky.
  2. I think I'd remove it before too long anyway. I feel like I'm going to need a Vector#lookup before too long and that'd need the override here. I guess the others... I dunno. I'm going to skip it for now.

@nik9000 nik9000 merged commit 507c1b6 into elastic:main Apr 28, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.15.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants