Skip to content

Commit

Permalink
ESQL: Speed up field name resolution (elastic#121221)
Browse files Browse the repository at this point in the history
Speeds up field name resolution when there are many many field names,
like in `HeapAttackIT`.

Relates to elastic#121112
  • Loading branch information
nik9000 committed Jan 29, 2025
1 parent 4fb1ec9 commit c179f52
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,11 @@ static PreAnalysisResult fieldNames(LogicalPlan parsed, Set<String> enrichPolicy
// for example "from test | eval x = salary | stats max = max(x) by gender"
// remove the UnresolvedAttribute "x", since that is an Alias defined in "eval"
AttributeSet planRefs = p.references();
Set<String> fieldNames = planRefs.names();
p.forEachExpressionDown(Alias.class, alias -> {
// do not remove the UnresolvedAttribute that has the same name as its alias, ie "rename id = id"
// or the UnresolvedAttributes that are used in Functions that have aliases "STATS id = MAX(id)"
if (planRefs.names().contains(alias.name())) {
if (fieldNames.contains(alias.name())) {
return;
}
references.removeIf(attr -> matchByName(attr, alias.name(), keepCommandReferences.contains(attr)));
Expand Down

0 comments on commit c179f52

Please sign in to comment.