Skip to content

Commit 159ab39

Browse files
committed
Update
1 parent cc575c2 commit 159ab39

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

docs/changelog/127563.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pr: 127563
2-
summary: "ESQL: Avoid regex extract attributes removal"
2+
summary: "ESQL: Avoid unintended attribute removal"
33
area: ES|QL
44
type: bug
55
issues:

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,13 @@ static PreAnalysisResult fieldNames(LogicalPlan parsed, Set<String> enrichPolicy
664664
AttributeSet planRefs = p.references();
665665
Set<String> fieldNames = planRefs.names();
666666
canRemoveAliases[1] = true;
667-
p.forEachDown(plan -> {
668-
if (canRemoveAliases[1] && couldOverrideAliases(plan)) {
667+
// go down each plan and remove aliases until we meet a plan that can override aliases
668+
p.forEachDown(c -> {
669+
if (canRemoveAliases[1] && couldOverrideAliases(c)) {
669670
canRemoveAliases[1] = false;
670671
}
671672
if (canRemoveAliases[1]) {
672-
plan.forEachExpression(Alias.class, alias -> {
673+
c.forEachExpression(Alias.class, alias -> {
673674
// do not remove the UnresolvedAttribute that has the same name as its alias, ie "rename id AS id"
674675
// or the UnresolvedAttributes that are used in Functions that have aliases "STATS id = MAX(id)"
675676
if (fieldNames.contains(alias.name())) {

0 commit comments

Comments
 (0)