Skip to content

Conversation

@idegtiarenko
Copy link
Contributor

Lookup indices must be resolved for every remote cluster that is going to be queried. Today list of remotes is derived from the index expression. With CPS/flat expressions remotes should be derived from the resolved main indices. This change moves lookup index resolution after main index resolution so that it will be possible to use main index resolution when deriving lookup indices remotes.

Closes: es-12613

Lookup indices must be resolved for every remote cluster that is going to be queried.
Today list of remotes is derived from the index expression. With CPS/flat expressions remotes should be derived from the resolved main indices.
This change moves lookup index resolution after main index resolution so that it will be possible to use main index resolution when deriving lookup indices remotes.
@idegtiarenko idegtiarenko added >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.2.0 labels Sep 4, 2025
@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Contributor

@luigidellaquila luigidellaquila left a comment

Choose a reason for hiding this comment

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

The comment first resolve the lookup indices, then the main indices seems to be very on purpose, but the CI is happy, and checking the code I don't see any dependencies between the two resolutions, so it LGTM.

Just for reference, that comment was introduced by #117246, but there is no further explanation in the PR

}
listener.<PreAnalysisResult>andThen((l, result) -> preAnalyzeMainIndices(preAnalysis, executionInfo, result, requestFilter, l))
.<LogicalPlan>andThen((l, result) -> analyzeWithRetry(parsed, requestFilter, preAnalysis, executionInfo, result, l))
.<PreAnalysisResult>andThen((l, r) -> resolveInferences(parsed, r, l))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why inferences stay on top of main indices? I see that enrich adds fields so it has to be on top, but inference doesn't do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not see a strong reason for that. Inference resolution result is not used in main or lookup index FC.
I believe we can move it if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to move it so if we ever need the cluster context for it (which we may) we'd have it. And on general principle so it's not confusing why some things happen before the main lookup and some after.

@idegtiarenko idegtiarenko merged commit 4056a79 into elastic:main Sep 5, 2025
33 checks passed
@idegtiarenko idegtiarenko deleted the es-12613_resolve_main_indices_before_lookup branch September 5, 2025 07:00
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.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants