Skip to content

Commit 732267f

Browse files
authored
ESQL: Speed up field name resolution (#121221) (#121228)
Speeds up field name resolution when there are many many field names, like in `HeapAttackIT`. Relates to #121112
1 parent 0493033 commit 732267f

File tree

1 file changed

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

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,11 @@ static PreAnalysisResult fieldNames(LogicalPlan parsed, Set<String> enrichPolicy
622622
// for example "from test | eval x = salary | stats max = max(x) by gender"
623623
// remove the UnresolvedAttribute "x", since that is an Alias defined in "eval"
624624
AttributeSet planRefs = p.references();
625+
Set<String> fieldNames = planRefs.names();
625626
p.forEachExpressionDown(Alias.class, alias -> {
626627
// do not remove the UnresolvedAttribute that has the same name as its alias, ie "rename id = id"
627628
// or the UnresolvedAttributes that are used in Functions that have aliases "STATS id = MAX(id)"
628-
if (planRefs.names().contains(alias.name())) {
629+
if (fieldNames.contains(alias.name())) {
629630
return;
630631
}
631632
references.removeIf(attr -> matchByName(attr, alias.name(), keepCommandReferences.contains(attr)));

0 commit comments

Comments
 (0)