Skip to content

Commit 210a1b8

Browse files
committed
Improve minTransportVersion over multiple field-caps calls
1 parent d2b40ce commit 210a1b8

File tree

1 file changed

+7
-6
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session

1 file changed

+7
-6
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,6 @@ public void analyzedPlan(
521521

522522
PreAnalyzer.PreAnalysis preAnalysis = preAnalyzer.preAnalyze(parsed);
523523
PreAnalysisResult result = FieldNameUtils.resolveFieldNames(parsed, preAnalysis.enriches().isEmpty() == false);
524-
if (preAnalysis.indexes().isEmpty()) {
525-
// Happens with no main indices, e.g. ROW a = 1 (even if there are lookup indices, but views and sub-queries will not lead here)
526-
result = result.withMinimumTransportVersion(TransportVersion.current());
527-
}
528524
String description = requestFilter == null ? "the only attempt without filter" : "first attempt with filter";
529525

530526
resolveIndicesAndAnalyze(
@@ -866,7 +862,6 @@ private void preAnalyzeMainIndices(
866862
// return empty resolution if the expression is pure CCS and resolved no remote clusters (like no-such-cluster*:index)
867863
listener.onResponse(
868864
result.withIndices(indexPattern, IndexResolution.valid(new EsIndex(indexPattern.indexPattern(), Map.of(), Map.of())))
869-
.withMinimumTransportVersion(TransportVersion.current())
870865
);
871866
} else {
872867
IndexMode indexMode = preAnalysis.indexes().get(indexPattern);
@@ -1024,7 +1019,7 @@ public record PreAnalysisResult(
10241019
) {
10251020

10261021
public PreAnalysisResult(Set<String> fieldNames, Set<String> wildcardJoinIndices) {
1027-
this(fieldNames, wildcardJoinIndices, Map.of(), new HashMap<>(), null, InferenceResolution.EMPTY, null);
1022+
this(fieldNames, wildcardJoinIndices, Map.of(), new HashMap<>(), null, InferenceResolution.EMPTY, TransportVersion.current());
10281023
}
10291024

10301025
PreAnalysisResult withIndices(IndexPattern indexPattern, IndexResolution indices) {
@@ -1071,6 +1066,12 @@ PreAnalysisResult withInferenceResolution(InferenceResolution inferenceResolutio
10711066
}
10721067

10731068
PreAnalysisResult withMinimumTransportVersion(TransportVersion minimumTransportVersion) {
1069+
if (this.minimumTransportVersion != null) {
1070+
if (this.minimumTransportVersion.equals(minimumTransportVersion)) {
1071+
return this;
1072+
}
1073+
minimumTransportVersion = TransportVersion.min(this.minimumTransportVersion, minimumTransportVersion);
1074+
}
10741075
return new PreAnalysisResult(
10751076
fieldNames,
10761077
wildcardJoinIndices,

0 commit comments

Comments
 (0)