Skip to content

Commit 71360df

Browse files
committed
comments
1 parent bebf1bd commit 71360df

File tree

10 files changed

+46
-28
lines changed

10 files changed

+46
-28
lines changed

docs/reference/query-languages/esql/_snippets/functions/examples/delta.md

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/_snippets/functions/examples/increase.md

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/definition/functions/delta.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/definition/functions/increase.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/docs/functions/delta.md

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/docs/functions/increase.md

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,20 @@ null | prod | 2024-05-10T00:03:00.000Z
6666
delta_with_filtering
6767
required_capability: ts_command_v0
6868
required_capability: delta_ts_agg
69-
TS k8s | WHERE pod == "one" | STATS tx = sum(delta(network.bytes_in)) BY cluster, time_bucket = bucket(@timestamp, 10minute) | SORT time_bucket, cluster | LIMIT 10;
69+
// tag::delta[]
70+
TS k8s
71+
| WHERE pod == "one"
72+
| STATS tx = sum(delta(network.bytes_in)) BY cluster, time_bucket = bucket(@timestamp, 10minute)
73+
// end::delta[]
74+
| SORT time_bucket, cluster | LIMIT 10;
7075

76+
// tag::delta-result[]
7177
tx:double | cluster:keyword | time_bucket:datetime
7278
-351.0 | prod | 2024-05-10T00:00:00.000Z
7379
552.0 | qa | 2024-05-10T00:00:00.000Z
7480
127.0 | staging | 2024-05-10T00:00:00.000Z
7581
280.0 | prod | 2024-05-10T00:10:00.000Z
82+
// end::delta-result[]
7683
73.0 | qa | 2024-05-10T00:10:00.000Z
7784
-600.0 | staging | 2024-05-10T00:10:00.000Z
7885
-22.0 | prod | 2024-05-10T00:20:00.000Z
@@ -83,20 +90,16 @@ tx:double | cluster:keyword | time_bucket:datetime
8390
delta_with_inline_filtering
8491
required_capability: ts_command_v0
8592
required_capability: delta_ts_agg
86-
// tag::delta[]
8793
TS k8s
8894
| STATS tx = sum(delta(network.bytes_in)) WHERE pod == "one" BY cluster, time_bucket = bucket(@timestamp, 10minute)
89-
// end::delta[]
9095
| SORT time_bucket, cluster | LIMIT 10;
9196

92-
// tag::delta-result[]
9397
tx:double | cluster:keyword | time_bucket:datetime
9498
-351.0 | prod | 2024-05-10T00:00:00.000Z
9599
552.0 | qa | 2024-05-10T00:00:00.000Z
96100
117.0 | staging | 2024-05-10T00:00:00.000Z
97101
280.0 | prod | 2024-05-10T00:10:00.000Z
98102
73.0 | qa | 2024-05-10T00:10:00.000Z
99-
// end::delta-result[]
100103
-600.0 | staging | 2024-05-10T00:10:00.000Z
101104
-22.0 | prod | 2024-05-10T00:20:00.000Z
102105
-711.0 | qa | 2024-05-10T00:20:00.000Z

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,20 @@ null | prod | 2024-05-10T00:03:00.000Z
5454

5555
idelta_with_filtering
5656
required_capability: ts_command_v0
57-
TS k8s | WHERE pod == "one" | STATS tx = sum(idelta(network.bytes_in)) BY cluster, time_bucket = bucket(@timestamp, 10minute) | SORT time_bucket, cluster | LIMIT 10;
57+
// tag::idelta[]
58+
TS k8s
59+
| WHERE pod == "one"
60+
| STATS tx = sum(idelta(network.bytes_in)) BY cluster, time_bucket = bucket(@timestamp, 10minute)
61+
// end::idelta[]
62+
| SORT time_bucket, cluster | LIMIT 10;
5863

64+
// tag::idelta-result[]
5965
tx:double | cluster:keyword | time_bucket:datetime
6066
-224.0 | prod | 2024-05-10T00:00:00.000Z
6167
791.0 | qa | 2024-05-10T00:00:00.000Z
6268
534.0 | staging | 2024-05-10T00:00:00.000Z
6369
-448.0 | prod | 2024-05-10T00:10:00.000Z
70+
// end::idelta-result[]
6471
-560.0 | qa | 2024-05-10T00:10:00.000Z
6572
-512.0 | staging | 2024-05-10T00:10:00.000Z
6673
915.0 | prod | 2024-05-10T00:20:00.000Z
@@ -70,20 +77,16 @@ tx:double | cluster:keyword | time_bucket:datetime
7077

7178
idelta_with_inline_filtering
7279
required_capability: ts_command_v0
73-
// tag::delta[]
7480
TS k8s
7581
| STATS tx = sum(idelta(network.bytes_in)) WHERE pod == "one" BY cluster, time_bucket = bucket(@timestamp, 10minute)
76-
// end::delta[]
7782
| SORT time_bucket, cluster | LIMIT 10;
7883

79-
// tag::delta-result[]
8084
tx:double | cluster:keyword | time_bucket:datetime
8185
-224.0 | prod | 2024-05-10T00:00:00.000Z
8286
791.0 | qa | 2024-05-10T00:00:00.000Z
8387
534.0 | staging | 2024-05-10T00:00:00.000Z
8488
-448.0 | prod | 2024-05-10T00:10:00.000Z
8589
-560.0 | qa | 2024-05-10T00:10:00.000Z
86-
// end::delta-result[]
8790
-512.0 | staging | 2024-05-10T00:10:00.000Z
8891
915.0 | prod | 2024-05-10T00:20:00.000Z
8992
9.0 | qa | 2024-05-10T00:20:00.000Z

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,19 @@ null | 2024-05-10T00:01:00.000Z
6868
increase_with_filtering
6969
required_capability: increase
7070
required_capability: ts_command_v0
71-
TS k8s | WHERE pod == "one"
71+
// tag::increase[]
72+
TS k8s
73+
| WHERE pod == "one"
7274
| STATS increase_bytes_in = sum(increase(network.total_bytes_in)) BY cluster, time_bucket = bucket(@timestamp, 10minute)
75+
// end::increase[]
7376
| SORT time_bucket, cluster | LIMIT 10;
7477

78+
// tag::increase-result[]
7579
increase_bytes_in:double | cluster:keyword | time_bucket:datetime
7680
2418.8749174917493 | prod | 2024-05-10T00:00:00.000Z
7781
5973.5 | qa | 2024-05-10T00:00:00.000Z
7882
2545.467283950617 | staging | 2024-05-10T00:00:00.000Z
83+
// end::increase-result[]
7984
6713.028169014084 | prod | 2024-05-10T00:10:00.000Z
8085
7333.555555555556 | qa | 2024-05-10T00:10:00.000Z
8186
1830.2228941684662 | staging | 2024-05-10T00:10:00.000Z
@@ -87,19 +92,15 @@ increase_bytes_in:double | cluster:keyword | time_bucket:datetime
8792
increase_with_inline_filtering
8893
required_capability: increase
8994
required_capability: ts_command_v0
90-
// tag::increase[]
9195
TS k8s
9296
| STATS increase_bytes_in = sum(increase(network.total_bytes_in)) WHERE pod == "one" BY cluster, time_bucket = bucket(@timestamp, 10minute)
93-
// end::increase[]
9497
| SORT time_bucket, cluster | LIMIT 10;
9598

96-
// tag::increase-result[]
9799
increase_bytes_in:double | cluster:keyword | time_bucket:datetime
98100
2418.8749174917493 | prod | 2024-05-10T00:00:00.000Z
99101
5973.5 | qa | 2024-05-10T00:00:00.000Z
100102
2545.467283950617 | staging | 2024-05-10T00:00:00.000Z
101103
6713.028169014084 | prod | 2024-05-10T00:10:00.000Z
102-
// end::increase-result[]
103104
7333.555555555556 | qa | 2024-05-10T00:10:00.000Z
104105
1830.2228941684662 | staging | 2024-05-10T00:10:00.000Z
105106
1326.095015576324 | prod | 2024-05-10T00:20:00.000Z

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/DeltaTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,21 @@ private static TestCaseSupplier makeSupplier(TestCaseSupplier.TypedDataSupplier
116116
if (dataRows.size() < 2) {
117117
matcher = Matchers.nullValue();
118118
} else {
119-
var maxrate = switch (fieldTypedData.type().widenSmallNumeric()) {
119+
var maxdelta = switch (fieldTypedData.type().widenSmallNumeric()) {
120120
case INTEGER, COUNTER_INTEGER -> dataRows.stream().mapToInt(v -> (Integer) v).max().orElse(0);
121121
case LONG, COUNTER_LONG -> dataRows.stream().mapToLong(v -> (Long) v).max().orElse(0L);
122122
case DOUBLE, COUNTER_DOUBLE -> dataRows.stream().mapToDouble(v -> (Double) v).max().orElse(0.0);
123123
default -> throw new IllegalStateException("Unexpected value: " + fieldTypedData.type());
124124
};
125-
var minrate = switch (fieldTypedData.type().widenSmallNumeric()) {
125+
var mindelta = switch (fieldTypedData.type().widenSmallNumeric()) {
126126
case INTEGER, COUNTER_INTEGER -> dataRows.stream().mapToInt(v -> (Integer) v).min().orElse(0);
127127
case LONG, COUNTER_LONG -> dataRows.stream().mapToLong(v -> (Long) v).min().orElse(0L);
128128
case DOUBLE, COUNTER_DOUBLE -> dataRows.stream().mapToDouble(v -> (Double) v).min().orElse(0.0);
129129
default -> throw new IllegalStateException("Unexpected value: " + fieldTypedData.type());
130130
};
131-
maxrate = Math.max(maxrate, maxrate - Math.min(minrate, 0));
132-
minrate = -maxrate;
133-
matcher = Matchers.allOf(Matchers.greaterThanOrEqualTo(minrate), Matchers.lessThanOrEqualTo(maxrate));
131+
maxdelta = Math.max(maxdelta, maxdelta - Math.min(mindelta, 0));
132+
mindelta = -maxdelta;
133+
matcher = Matchers.allOf(Matchers.greaterThanOrEqualTo(mindelta), Matchers.lessThanOrEqualTo(maxdelta));
134134
}
135135
return new TestCaseSupplier.TestCase(
136136
List.of(fieldTypedData, timestampsField, sliceIndexType, nextTimestampType),

0 commit comments

Comments
 (0)