Skip to content

Commit f7f7d1a

Browse files
committed
capab
1 parent 8196afc commit f7f7d1a

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/k8s-timeseries.csv-spec

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -723,22 +723,43 @@ mx:integer | tbucket:datetime
723723

724724
derivative_of_gauge_metric
725725
required_capability: ts_command_v0
726+
required_capability: ts_linreg
726727

727728
TS k8s
729+
| WHERE pod == "three"
728730
| STATS max_deriv = max(deriv(network.cost)) BY time_bucket = bucket(@timestamp,5minute), pod
731+
| EVAL max_deriv = ROUND(max_deriv,6)
732+
| KEEP max_deriv, time_bucket, pod
729733
| SORT pod, time_bucket
730-
| LIMIT 10
734+
| LIMIT 5
735+
;
736+
737+
max_deriv:double | time_bucket:datetime | pod:keyword
738+
9.3E-5 | 2024-05-10T00:00:00.000Z | three
739+
3.8E-5 | 2024-05-10T00:05:00.000Z | three
740+
-2.0E-5 | 2024-05-10T00:10:00.000Z | three
741+
-1.0E-6 | 2024-05-10T00:15:00.000Z | three
742+
0.0 | 2024-05-10T00:20:00.000Z | three
743+
731744
;
732745

733-
max_deriv:double | time_bucket:datetime | pod:keyword
734-
2.7573529411764707E-5 | 2024-05-10T00:00:00.000Z | one
735-
-9.657960185083621E-6 | 2024-05-10T00:05:00.000Z | one
736-
2.6771965095388827E-5 | 2024-05-10T00:10:00.000Z | one
737-
4.405946549223768E-5 | 2024-05-10T00:15:00.000Z | one
738-
8.564814814814814E-5 | 2024-05-10T00:20:00.000Z | one
739-
9.27740599107712E-5 | 2024-05-10T00:00:00.000Z | three
740-
3.80263223304832E-5 | 2024-05-10T00:05:00.000Z | three
741-
-1.9699890788329952E-5 | 2024-05-10T00:10:00.000Z | three
742-
-1.2087599544937429E-6 | 2024-05-10T00:15:00.000Z | three
743-
NaN | 2024-05-10T00:20:00.000Z | three
746+
derivative_compared_to_rate
747+
required_capability: ts_command_v0
748+
required_capability: ts_linreg
749+
750+
TS k8s
751+
| STATS max_deriv = max(deriv(to_long(network.total_bytes_in))), max_rate = max(rate(network.total_bytes_in)) BY time_bucket = bucket(@timestamp,5minute), cluster
752+
| EVAL max_deriv = ROUND(max_deriv,6), max_rate = ROUND(max_rate,6)
753+
| KEEP max_deriv, max_rate, time_bucket, cluster
754+
| SORT cluster, time_bucket
755+
| LIMIT 5
756+
;
757+
758+
max_deriv:double | max_rate:double | time_bucket:datetime | cluster:keyword
759+
0.0855 | 8.120833 | 2024-05-10T00:00:00.000Z | prod
760+
0.004933 | 6.451737 | 2024-05-10T00:05:00.000Z | prod
761+
0.008922 | 11.562738 | 2024-05-10T00:10:00.000Z | prod
762+
0.016623 | 11.860806 | 2024-05-10T00:15:00.000Z | prod
763+
0.0 | 6.980661 | 2024-05-10T00:20:00.000Z | prod
764+
744765
;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,7 @@ public enum Cap {
14771477
*/
14781478
PERCENTILE_OVER_TIME,
14791479
VARIANCE_STDDEV_OVER_TIME,
1480+
TS_LINREG,
14801481
/**
14811482
* INLINE STATS fix incorrect prunning of null filtering
14821483
* https://github.com/elastic/elasticsearch/pull/135011

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
1111
import org.elasticsearch.compute.aggregation.AggregatorFunctionSupplier;
12-
import org.elasticsearch.compute.aggregation.DerivGroupingAggregatorFunction;
12+
import org.elasticsearch.compute.aggregation.DerivDoubleGroupingAggregatorFunction;
1313
import org.elasticsearch.compute.aggregation.DerivIntGroupingAggregatorFunction;
1414
import org.elasticsearch.compute.aggregation.DerivLongGroupingAggregatorFunction;
1515
import org.elasticsearch.xpack.esql.core.expression.Expression;
@@ -102,7 +102,7 @@ public AggregatorFunctionSupplier supplier() {
102102
return switch (type) {
103103
case INTEGER -> new DerivIntGroupingAggregatorFunction.Supplier();
104104
case LONG -> new DerivLongGroupingAggregatorFunction.Supplier();
105-
case DOUBLE -> new DerivGroupingAggregatorFunction.Supplier();
105+
case DOUBLE -> new DerivDoubleGroupingAggregatorFunction.Supplier();
106106
default -> throw new IllegalArgumentException("Unsupported data type for deriv aggregation: " + type);
107107
};
108108
}

0 commit comments

Comments
 (0)