Skip to content

ESQL: More care when pushing expression to load#139412

Merged
nik9000 merged 1 commit intoelastic:mainfrom
nik9000:esql_more_careful_push
Dec 12, 2025
Merged

ESQL: More care when pushing expression to load#139412
nik9000 merged 1 commit intoelastic:mainfrom
nik9000:esql_more_careful_push

Conversation

@nik9000
Copy link
Copy Markdown
Member

@nik9000 nik9000 commented Dec 11, 2025

We need to be even more careful when pushing expressions into field loading. With this change we only push if the EVAL/WHERE/STATS has exactly one "leaf" node ancestor AND it's valid for pushing.

This prevents pushing into "StubRelations" like we get with this plan:

FROM k8s-downsampled
| INLINE STATS tx_max = MAX(network.eth0.tx) BY pod

In the future we should be able to push if we can push into all relations rather than checking that there is just one. But baby steps.

Closes #138620

With this change we only push if the EVAL/WHERE/STATS has exactly one
"leaf" node ancestor *AND* it's valid for pushing.

This prevents pushing into "StubRelations" like we get with this plan:
```
FROM k8s-downsampled
| INLINE STATS tx_max = MAX(network.eth0.tx) BY pod
```

In the future we should be able to push if we can push into *all*
relations rather than checking that there is just one. But baby steps.

Closes elastic#138620
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 11, 2025
@nik9000 nik9000 added >non-issue and removed Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) labels Dec 12, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 12, 2025
@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented Dec 12, 2025

I believe we should be even more careful about how we push than this is, but I can't come up with a query where it makes a difference right now.

@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented Dec 12, 2025

I'd like to add another test to PushExpressionToLoadIT with the example from the unit test. Just to prove that we push at the right times there. We know we don't fail to run the query - but it'd be nice to have a positive test for that. But I don't think we have to hold up merging on that. But that's a choice for reviewers I think.

Copy link
Copy Markdown
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

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

LGTM 👍

* for "can't push".
* </p>
*/
private class Primaries {
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.

Nice!

@nik9000 nik9000 merged commit 9e09c22 into elastic:main Dec 12, 2025
34 checks passed
@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented Dec 12, 2025

Thanks @carlosdelest !

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) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ES|QL] Prevent fused fields from being pushed into StubRelations

3 participants