Skip to content

Commit a29e9f4

Browse files
ES|QL: Make ResolveUnionTypes rule stateless (elastic#136492) (elastic#136527)
1 parent baaf23d commit a29e9f4

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

docs/changelog/136492.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 136492
2+
summary: Make `ResolveUnionTypes` rule stateless
3+
area: ES|QL
4+
type: bug
5+
issues: []

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,11 +1365,9 @@ private static class ResolveUnionTypes extends Rule<LogicalPlan, LogicalPlan> {
13651365

13661366
record TypeResolutionKey(String fieldName, DataType fieldType) {}
13671367

1368-
private List<FieldAttribute> unionFieldAttributes;
1369-
13701368
@Override
13711369
public LogicalPlan apply(LogicalPlan plan) {
1372-
unionFieldAttributes = new ArrayList<>();
1370+
List<FieldAttribute> unionFieldAttributes = new ArrayList<>();
13731371
// Collect field attributes from previous runs
13741372
plan.forEachUp(EsRelation.class, rel -> {
13751373
for (Attribute attr : rel.output()) {
@@ -1379,10 +1377,10 @@ public LogicalPlan apply(LogicalPlan plan) {
13791377
}
13801378
});
13811379

1382-
return plan.transformUp(LogicalPlan.class, p -> p.childrenResolved() == false ? p : doRule(p));
1380+
return plan.transformUp(LogicalPlan.class, p -> p.childrenResolved() == false ? p : doRule(p, unionFieldAttributes));
13831381
}
13841382

1385-
private LogicalPlan doRule(LogicalPlan plan) {
1383+
private LogicalPlan doRule(LogicalPlan plan, List<FieldAttribute> unionFieldAttributes) {
13861384
int alreadyAddedUnionFieldAttributes = unionFieldAttributes.size();
13871385
// See if the eval function has an unresolved MultiTypeEsField field
13881386
// Replace the entire convert function with a new FieldAttribute (containing type conversion knowledge)

0 commit comments

Comments
 (0)