Skip to content

Commit 77855e7

Browse files
committed
fixup
1 parent 87eeb7b commit 77855e7

File tree

1 file changed

+11
-9
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate

1 file changed

+11
-9
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/Deriv.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ public Deriv(Source source, @Param(name = "field", type = { "long", "integer", "
4343
}
4444

4545
public Deriv(Source source, Expression field, Expression timestamp) {
46-
super(source, field, Literal.TRUE, NO_WINDOW, List.of(timestamp));
47-
this.timestamp = timestamp;
46+
this(source, field, Literal.TRUE, timestamp, NO_WINDOW);
4847
}
4948

50-
public Deriv(Source source, Expression field, Expression filter, Expression timestamp) {
51-
super(source, field, filter, NO_WINDOW, List.of(timestamp));
49+
public Deriv(Source source, Expression field, Expression filter, Expression window, Expression timestamp) {
50+
super(source, field, filter, window, List.of(timestamp));
5251
this.timestamp = timestamp;
5352
}
5453

@@ -57,6 +56,7 @@ private Deriv(org.elasticsearch.common.io.stream.StreamInput in) throws java.io.
5756
Source.readFrom((PlanStreamInput) in),
5857
in.readNamedWriteable(Expression.class),
5958
in.readNamedWriteable(Expression.class),
59+
in.readNamedWriteable(Expression.class),
6060
in.readNamedWriteable(Expression.class)
6161
);
6262
}
@@ -68,7 +68,7 @@ public AggregateFunction perTimeSeriesAggregation() {
6868

6969
@Override
7070
public AggregateFunction withFilter(Expression filter) {
71-
return new Deriv(source(), field(), filter, timestamp);
71+
return new Deriv(source(), field(), filter, timestamp, window());
7272
}
7373

7474
@Override
@@ -78,17 +78,19 @@ public DataType dataType() {
7878

7979
@Override
8080
public Expression replaceChildren(List<Expression> newChildren) {
81-
if (newChildren.size() == 3) {
82-
return new Deriv(source(), newChildren.get(0), newChildren.get(1), newChildren.get(2));
81+
if (newChildren.size() == 4) {
82+
return new Deriv(source(), newChildren.get(0), newChildren.get(1), newChildren.get(2), newChildren.get(3));
83+
} else if (newChildren.size() == 3) {
84+
return new Deriv(source(), newChildren.get(0), newChildren.get(1), newChildren.get(2), timestamp);
8385
} else {
84-
assert newChildren.size() == 2;
86+
assert newChildren.size() == 2 : "Expected 2, 3, 4 children but got " + newChildren.size();
8587
return new Deriv(source(), newChildren.get(0), newChildren.get(1));
8688
}
8789
}
8890

8991
@Override
9092
protected NodeInfo<? extends Expression> info() {
91-
return NodeInfo.create(this, Deriv::new, field(), filter(), timestamp);
93+
return NodeInfo.create(this, Deriv::new, field(), filter(), window(), timestamp);
9294
}
9395

9496
@Override

0 commit comments

Comments
 (0)