Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/136492.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 136492
summary: Make `ResolveUnionTypes` rule stateless
area: ES|QL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -1365,11 +1365,9 @@ private static class ResolveUnionTypes extends Rule<LogicalPlan, LogicalPlan> {

record TypeResolutionKey(String fieldName, DataType fieldType) {}

private List<FieldAttribute> unionFieldAttributes;

@Override
public LogicalPlan apply(LogicalPlan plan) {
unionFieldAttributes = new ArrayList<>();
List<FieldAttribute> unionFieldAttributes = new ArrayList<>();
// Collect field attributes from previous runs
plan.forEachUp(EsRelation.class, rel -> {
for (Attribute attr : rel.output()) {
Expand All @@ -1379,10 +1377,10 @@ public LogicalPlan apply(LogicalPlan plan) {
}
});

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

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