Skip to content

Commit 3f1fba0

Browse files
ivanceamridula-s109
authored andcommitted
[ESQL] Fix SpatialDocValuesExtraction rule replacing TimeSeries agg node (elastic#129273)
`TimeSeriesAggregateExec` (TS) node inherits from `AggregateExec` (STATS). The `SpatialDocValuesExtraction` rule was replacing all `AggregateExec` instances with another `AggregateExec`, whether the same class or not.
1 parent 6852ded commit 3f1fba0

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/SpatialDocValuesExtraction.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,7 @@ && allowedForDocValues(fieldAttribute, ctx.searchStats(), agg, foundAttributes))
9797
}
9898
}
9999
if (changedAggregates) {
100-
exec = new AggregateExec(
101-
agg.source(),
102-
agg.child(),
103-
agg.groupings(),
104-
orderedAggregates,
105-
agg.getMode(),
106-
agg.intermediateAttributes(),
107-
agg.estimatedRowSize()
108-
);
100+
exec = agg.withAggregates(orderedAggregates);
109101
}
110102
}
111103
if (exec instanceof EvalExec evalExec) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/AggregateExec.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ public List<? extends NamedExpression> aggregates() {
120120
return aggregates;
121121
}
122122

123+
public AggregateExec withAggregates(List<? extends NamedExpression> newAggregates) {
124+
return new AggregateExec(source(), child(), groupings, newAggregates, mode, intermediateAttributes, estimatedRowSize);
125+
}
126+
123127
public AggregateExec withMode(AggregatorMode newMode) {
124128
return new AggregateExec(source(), child(), groupings, aggregates, newMode, intermediateAttributes, estimatedRowSize);
125129
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/TimeSeriesAggregateExec.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ public TimeSeriesAggregateExec replaceChild(PhysicalPlan newChild) {
9797
);
9898
}
9999

100+
@Override
101+
public AggregateExec withAggregates(List<? extends NamedExpression> newAggregates) {
102+
return new TimeSeriesAggregateExec(
103+
source(),
104+
child(),
105+
groupings(),
106+
newAggregates,
107+
getMode(),
108+
intermediateAttributes(),
109+
estimatedRowSize(),
110+
timeBucket
111+
);
112+
}
113+
114+
@Override
100115
public TimeSeriesAggregateExec withMode(AggregatorMode newMode) {
101116
return new TimeSeriesAggregateExec(
102117
source(),

0 commit comments

Comments
 (0)