diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java index 09ba8142bea7d..0c65af857cb89 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java @@ -64,7 +64,6 @@ import org.elasticsearch.xpack.esql.plan.IndexPattern; import org.elasticsearch.xpack.esql.plan.logical.Explain; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; -import org.elasticsearch.xpack.esql.plan.logical.inference.InferencePlan; import org.elasticsearch.xpack.esql.plan.logical.join.InlineJoin; import org.elasticsearch.xpack.esql.plan.logical.local.LocalRelation; import org.elasticsearch.xpack.esql.plan.logical.local.LocalSupplier; @@ -388,8 +387,13 @@ public void analyzedPlan( var listener = SubscribableListener.newForked( l -> enrichPolicyResolver.resolvePolicies(unresolvedPolicies, executionInfo, l) ) - .andThen((l, enrichResolution) -> resolveFieldNames(parsed, enrichResolution, l)) - .andThen((l, preAnalysisResult) -> resolveInferences(preAnalysis.inferencePlans, preAnalysisResult, l)); + .andThenApply(enrichResolution -> FieldNameUtils.resolveFieldNames(parsed, enrichResolution)) + .andThen( + (l, preAnalysisResult) -> inferenceRunner.resolveInferenceIds( + preAnalysis.inferencePlans, + l.map(preAnalysisResult::withInferenceResolution) + ) + ); // first resolve the lookup indices, then the main indices for (var index : preAnalysis.lookupIndices) { listener = listener.andThen((l, preAnalysisResult) -> preAnalyzeLookupIndex(index, preAnalysisResult, executionInfo, l)); @@ -742,18 +746,6 @@ private static void analyzeAndMaybeRetry( logicalPlanListener.onResponse(plan); } - private static void resolveFieldNames(LogicalPlan parsed, EnrichResolution enrichResolution, ActionListener l) { - ActionListener.completeWith(l, () -> FieldNameUtils.resolveFieldNames(parsed, enrichResolution)); - } - - private void resolveInferences( - List> inferencePlans, - PreAnalysisResult preAnalysisResult, - ActionListener l - ) { - inferenceRunner.resolveInferenceIds(inferencePlans, l.map(preAnalysisResult::withInferenceResolution)); - } - private PhysicalPlan logicalPlanToPhysicalPlan(LogicalPlan optimizedPlan, EsqlQueryRequest request) { PhysicalPlan physicalPlan = optimizedPhysicalPlan(optimizedPlan); physicalPlan = physicalPlan.transformUp(FragmentExec.class, f -> {