Skip to content

Commit 7e9a3a5

Browse files
committed
Some fixes
1 parent 5346535 commit 7e9a3a5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/ChangePointStates.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ private Block buildValuesBlock(BlockFactory blockFactory) {
124124

125125
// TODO: this needs to output multiple columns or a composite object, not a JSON blob.
126126
private BytesRef getChangePoint() {
127-
// TODO: this copying doesn't account for memory
127+
// TODO: probably reuse ES|QL sort/orderBy to get results in order
128+
// TODO: this copying/sorting doesn't account for memory
128129
List<TimeAndValue> list = new ArrayList<>(count);
129130
for (int i = 0; i < count; i++) {
130131
list.add(new TimeAndValue(timestamps.get(i), values.get(i)));

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ChangePoint extends AggregateFunction implements OptionalArgument,
4040
ChangePoint::new
4141
);
4242

43-
@FunctionInfo(returnType = { "string" }, description = "...", isAggregation = true)
43+
@FunctionInfo(returnType = { "string" }, description = "Detects spikes, dips, and change points in a metric", isAggregation = true)
4444
public ChangePoint(
4545
Source source,
4646
@Param(name = "field", type = { "double", "integer", "long" }, description = "field") Expression field,
@@ -73,12 +73,16 @@ Expression timestamp() {
7373

7474
@Override
7575
protected NodeInfo<ChangePoint> info() {
76-
return NodeInfo.create(this, ChangePoint::new, field(), timestamp());
76+
return NodeInfo.create(this, ChangePoint::new, field(), filter(), timestamp());
7777
}
7878

7979
@Override
8080
public ChangePoint replaceChildren(List<Expression> newChildren) {
81-
return new ChangePoint(source(), newChildren.get(0), newChildren.get(1), newChildren.get(2));
81+
if (newChildren.size() == 2) {
82+
return new ChangePoint(source(), newChildren.get(0), newChildren.get(1));
83+
} else {
84+
return new ChangePoint(source(), newChildren.get(0), newChildren.get(1), newChildren.get(2));
85+
}
8286
}
8387

8488
// TODO: this needs to output multiple columns or a composite object

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ setup:
9292
- gt: {esql.functions.to_long: $functions_to_long}
9393
- match: {esql.functions.coalesce: $functions_coalesce}
9494
# Testing for the entire function set isn't feasbile, so we just check that we return the correct count as an approximation.
95-
- length: {esql.functions: 130} # check the "sister" test below for a likely update to the same esql.functions length check
95+
- length: {esql.functions: 131} # check the "sister" test below for a likely update to the same esql.functions length check
9696

9797
---
9898
"Basic ESQL usage output (telemetry) non-snapshot version":

0 commit comments

Comments
 (0)