Skip to content

Commit faf6b75

Browse files
ES|QL: Make ResolveUnionTypes rule stateless (elastic#136492) (elastic#136527)
1 parent 9ad686f commit faf6b75

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
@@ -1442,11 +1442,9 @@ private static class ResolveUnionTypes extends Rule<LogicalPlan, LogicalPlan> {
14421442

14431443
record TypeResolutionKey(String fieldName, DataType fieldType) {}
14441444

1445-
private List<FieldAttribute> unionFieldAttributes;
1446-
14471445
@Override
14481446
public LogicalPlan apply(LogicalPlan plan) {
1449-
unionFieldAttributes = new ArrayList<>();
1447+
List<FieldAttribute> unionFieldAttributes = new ArrayList<>();
14501448
// Collect field attributes from previous runs
14511449
plan.forEachUp(EsRelation.class, rel -> {
14521450
for (Attribute attr : rel.output()) {
@@ -1456,10 +1454,10 @@ public LogicalPlan apply(LogicalPlan plan) {
14561454
}
14571455
});
14581456

1459-
return plan.transformUp(LogicalPlan.class, p -> p.childrenResolved() == false ? p : doRule(p));
1457+
return plan.transformUp(LogicalPlan.class, p -> p.childrenResolved() == false ? p : doRule(p, unionFieldAttributes));
14601458
}
14611459

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

0 commit comments

Comments
 (0)