Skip to content
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

ESQL: Read from the BlockFactory #100231

Merged
merged 10 commits into from
Oct 5, 2023
Merged

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Oct 3, 2023

This links the BlockFactory into the Block serialization code. With this blocks that are deserialized from over the wire are tracked.

This links the `BlockFactory` into the `Block` serialization code. With
this blocks that are deserialized from over the wire are tracked.
@nik9000 nik9000 requested review from dnhatn and ChrisHegarty October 3, 2023 20:37
@elasticsearchmachine elasticsearchmachine added the Team:QL (Deprecated) Meta label for query languages team label Oct 3, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)

@@ -68,6 +68,7 @@ public ElementType elementType() {

@Override
public Block filter(int... positions) {
close();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is so weird. Usually filter preserves a reference to the underlying block. But it doesn't for ConstantNullBlock and that's fine and good. But we presume that it does. This "simulates" that. I hate it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. this finds sucks. It's ok for now.

@@ -861,6 +861,7 @@ public void testFromStatsLimit() {
}
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/99826")
public void testFromLimit() {
try (EsqlQueryResponse results = run("from test | keep data | limit 2")) {
Copy link
Member Author

Choose a reason for hiding this comment

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

There's something funky going on with LimitOperator and I tried to track it down - you can see the tests I added. But I ultimately gave up. I think the problem here is that we finish the Operator and something on the exchange doesn't close. I'm not sure though.

@@ -52,6 +53,7 @@

import static org.hamcrest.Matchers.equalTo;

@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/99826")
Copy link
Member Author

Choose a reason for hiding this comment

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

I hate disabling this. ENRICH seems to work, but the IT isn't. It could be that we simply don't test the enrich path I'm breaking with this PR though.

Copy link
Member

Choose a reason for hiding this comment

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

You can leave it muted. I will integrate BlockFactory to the enrich operator.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks. I was digging around and learning a lot. But it wasn't quick.

Copy link
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.

This looks good. I've left a comment regarding the passing of the BlockFactory.

* to BigArrays, which we need to build the BlockFactory
* up front.
*/
blockFactoryHolder.blockFactory = blockFactory;
Copy link
Member

Choose a reason for hiding this comment

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

Can we create a custom StreamInput, such as PlanStreamInput, and then create and pass a BlockFactory whenever we deserialize a Page? Currently, we only deserialize Pages in two places: ExchangeResponse and LookupResponse for enrich.

Copy link
Contributor

Choose a reason for hiding this comment

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

++

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll have a look. I figured it'd amount to the same thing though because we have to figure out how to do that passing. But maybe it's later. I'll look.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did it! I do like this better.

Copy link
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

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

This is mostly very good. I think there is just a couple of outstanding comments.


if (lastInput != null) {
lastInput.releaseBlocks();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

++

assertThat(getValuesList(resp), hasSize(0));
assertThat(queriedIndices, empty());
queriedIndices.clear();
try (EsqlQueryResponse resp = run("from events_*", randomPragmas(), new RangeQueryBuilder("@timestamp").gte("2023-01-01"))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm.. I updated these tests to close the response, so created a merge conflict here. Sorry.

Copy link
Member Author

Choose a reason for hiding this comment

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

Merge conflicts are life.

* to BigArrays, which we need to build the BlockFactory
* up front.
*/
blockFactoryHolder.blockFactory = blockFactory;
Copy link
Contributor

Choose a reason for hiding this comment

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

++

@mattc58 mattc58 added v8.12.0 and removed v8.11.0 labels Oct 4, 2023
@nik9000 nik9000 added auto-backport Automatically create backport pull requests when merged v8.11.0 labels Oct 4, 2023
@nik9000
Copy link
Member Author

nik9000 commented Oct 4, 2023

@dnhatn and @ChrisHegarty, could you have another look? I've moved the BlockFactory to a StreamInput subclass. I intentionally only plugged it into the ExchangeResponse for now. Because ENRICH doesn't use the factory at all yet I figured that was safer. And we could plug that in later.

@nik9000
Copy link
Member Author

nik9000 commented Oct 4, 2023

The part 2 failure looks real. I'll look!

@dnhatn
Copy link
Member

dnhatn commented Oct 4, 2023

The part 2 failure looks real. I'll look!

@nik9000 #100259 helps releasing discarded Pages in ExchangeBuffer. And I pushed 63e6473 to fix the tests where manipulated ExchangeResponse. We should be good here.

Copy link
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.

I left a comment, but LGTM.

builder.beginPositionEntry();
for (int valueIndex = 0; valueIndex < valueCount; valueIndex++) {
builder.append$Type$(in.read$Type$());
try ($Type$Block.Builder builder = ((BlockStreamInput) in).blockFactory().new$Type$BlockBuilder(positions)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we prefer not to have a type cast here, but it should not block this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll grab that in a followup.

@nik9000 nik9000 merged commit 9f72ce0 into elastic:main Oct 5, 2023
nik9000 added a commit to nik9000/elasticsearch that referenced this pull request Oct 5, 2023
This links the `BlockFactory` into the `Block` serialization code. With
this blocks that are deserialized from over the wire are tracked.


Co-authored-by: Nhat Nguyen <[email protected]>
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.11

nik9000 added a commit that referenced this pull request Oct 5, 2023
This links the `BlockFactory` into the `Block` serialization code. With
this blocks that are deserialized from over the wire are tracked.

Co-authored-by: Nhat Nguyen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged >non-issue Team:QL (Deprecated) Meta label for query languages team v8.11.0 v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants