From 4adad780e681f68d1386bcb3eaf0206c9bd194fb Mon Sep 17 00:00:00 2001 From: Luigi Dell'Aquila Date: Mon, 13 Oct 2025 18:08:30 +0200 Subject: [PATCH 1/2] ES|QL: Make ResolveUnionTypes rule stateless --- .../org/elasticsearch/xpack/esql/analysis/Analyzer.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java index 58d74d0907c48..57bcf37b68de8 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java @@ -1845,15 +1845,13 @@ private static class ResolveUnionTypes extends Rule { record TypeResolutionKey(String fieldName, DataType fieldType) {} - private List unionFieldAttributes; - @Override public LogicalPlan apply(LogicalPlan plan) { - unionFieldAttributes = new ArrayList<>(); - return plan.transformUp(LogicalPlan.class, p -> p.childrenResolved() == false ? p : doRule(p)); + List unionFieldAttributes = new ArrayList<>(); + return plan.transformUp(LogicalPlan.class, p -> p.childrenResolved() == false ? p : doRule(p, unionFieldAttributes)); } - private LogicalPlan doRule(LogicalPlan plan) { + private LogicalPlan doRule(LogicalPlan plan, List unionFieldAttributes) { Holder alreadyAddedUnionFieldAttributes = new Holder<>(unionFieldAttributes.size()); // Collect field attributes from previous runs if (plan instanceof EsRelation rel) { From e029ca898c79f78d752f21e169a1c50d7168b4a0 Mon Sep 17 00:00:00 2001 From: Luigi Dell'Aquila Date: Mon, 13 Oct 2025 18:11:21 +0200 Subject: [PATCH 2/2] Update docs/changelog/136492.yaml --- docs/changelog/136492.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/136492.yaml diff --git a/docs/changelog/136492.yaml b/docs/changelog/136492.yaml new file mode 100644 index 0000000000000..5ae71a5cfa79f --- /dev/null +++ b/docs/changelog/136492.yaml @@ -0,0 +1,5 @@ +pr: 136492 +summary: Make `ResolveUnionTypes` rule stateless +area: ES|QL +type: bug +issues: []