Skip to content

Commit 2479bfa

Browse files
Fix
1 parent 7d67986 commit 2479bfa

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ public static PreAnalysisResult resolveFieldNames(LogicalPlan parsed, EnrichReso
102102

103103
var canRemoveAliases = new Holder<>(true);
104104
var needsAllFields = new Holder<>(parsed.anyMatch(p -> shouldCollectReferencedFields(p, inlinestatsAggs)) == false);
105+
if (needsAllFields.get()) {
106+
// no explicit columns selection, for example "from employees"
107+
// also, inlinestats only adds columns to the existent output, its Aggregate shouldn't interfere with potentially using "*"
108+
return new PreAnalysisResult(enrichResolution, IndexResolver.ALL_FIELDS, Set.of());
109+
}
105110

106111
var processingLambda = new Holder<Function<LogicalPlan, Boolean>>();
107112
processingLambda.set((LogicalPlan p) -> {// go over each plan top-down
@@ -117,7 +122,8 @@ public static PreAnalysisResult resolveFieldNames(LogicalPlan parsed, EnrichReso
117122
assert return_result;
118123
if (referencesBuilder.get().isEmpty()) {
119124
needsAllFields.set(true);
120-
return true;
125+
// Early return.
126+
return false;
121127
}
122128
forkRefsResult.addAll(referencesBuilder.get());
123129
}
@@ -210,8 +216,6 @@ public static PreAnalysisResult resolveFieldNames(LogicalPlan parsed, EnrichReso
210216
parsed.forEachDownMayReturnEarly(processingLambda.get());
211217

212218
if (needsAllFields.get()) {
213-
// no explicit columns selection, for example "from employees"
214-
// also, inlinestats only adds columns to the existent output, its Aggregate shouldn't interfere with potentially using "*"
215219
return new PreAnalysisResult(enrichResolution, IndexResolver.ALL_FIELDS, Set.of());
216220
}
217221

0 commit comments

Comments
 (0)