Skip to content

Commit cf2a9ac

Browse files
committed
PromQL: Fix avg_over_time param passing
1 parent 46dcdbf commit cf2a9ac

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/promql/function/PromqlFunctionRegistry.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private static FunctionDefinition[][] functionDefinitions() {
7070
withinSeries("rate", Rate::new) },
7171
// Aggregation range functions
7272
new FunctionDefinition[] {
73-
withinSeriesOverTime("avg_over_time", AvgOverTime::new),
73+
withinSeriesOverTimeWithWindow("avg_over_time", AvgOverTime::new),
7474
withinSeriesOverTime("count_over_time", CountOverTime::new),
7575
withinSeriesOverTime("max_over_time", MaxOverTime::new),
7676
withinSeriesOverTime("min_over_time", MinOverTime::new),
@@ -210,6 +210,16 @@ private static FunctionDefinition withinSeriesOverTime(String name, OverTimeWith
210210
);
211211
}
212212

213+
// NB: There's no longer a single argument constructor so accept the dual one while passing on a NO_WINDOW
214+
private static FunctionDefinition withinSeriesOverTimeWithWindow(String name, OverTimeWithinSeriesBinary<?> builder) {
215+
return new FunctionDefinition(
216+
name,
217+
FunctionType.WITHIN_SERIES_AGGREGATION,
218+
Arity.ONE,
219+
(source, params) -> builder.build(source, params.get(0), AggregateFunction.NO_WINDOW)
220+
);
221+
}
222+
213223
private static FunctionDefinition withinSeries(String name, WithinSeries<?> builder) {
214224
return new FunctionDefinition(name, FunctionType.WITHIN_SERIES_AGGREGATION, Arity.ONE, (source, params) -> {
215225
Expression valueField = params.get(0);

0 commit comments

Comments
 (0)