Skip to content

Commit 3e52ef1

Browse files
committed
DEV: update TS cmds etc. with NaN support
1 parent 7825f38 commit 3e52ef1

File tree

12 files changed

+203
-103
lines changed

12 files changed

+203
-103
lines changed

content/commands/ts.add.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Unix time is the number of milliseconds that have elapsed since 00:00:00 UTC on
112112

113113
<details open><summary><code>value</code></summary>
114114

115-
is (double) numeric data value of the sample. The double number should follow [RFC 7159](https://tools.ietf.org/html/rfc7159) (JSON standard). In particular, the parser rejects overly large values that do not fit in binary64. It does not accept NaN or infinite values.
115+
is (double) numeric data value of the sample. The double number should follow [RFC 7159](https://tools.ietf.org/html/rfc7159) (JSON standard). In particular, the parser rejects overly large values that do not fit in binary64. It does not accept infinite values. NaN (Not a Number) values are supported starting from Redis 8.6.
116116
</details>
117117

118118
<note><b>Notes:</b>
@@ -173,6 +173,8 @@ This override is effective only for this single command and does not set the tim
173173
- `MAX`: only override if the value is higher than the existing value
174174
- `SUM`: If a previous sample exists, add the new sample to it so that the updated value is set to (previous + new). If no previous sample exists, the value is set to the new value.
175175

176+
<note><b>NaN Handling (Redis 8.6+):</b> When using `MIN`, `MAX`, or `SUM` policies, an error is returned if there is an existing value in the specified timestamp and either the previous or the new value (but not both) are NaN.</note>
177+
176178
This argument has no effect when a new time series is created by this command.
177179
</details>
178180

@@ -192,6 +194,8 @@ When not specified: set to the global [IGNORE_MAX_TIME_DIFF]({{< relref "develop
192194

193195
These parameters are used when creating a new time series to set the per-key parameters, and are ignored when called with an existing time series (the existing per-key configuration parameters is used).
194196

197+
<note><b>NaN Handling (Redis 8.6+):</b> NaN values are never regarded as duplicates when using the `IGNORE` parameters.</note>
198+
195199
</details>
196200

197201
<details open><summary><code>LABELS {label value}...</code></summary>

content/commands/ts.createrule.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ arguments:
4949
since: 1.8.0
5050
token: TWA
5151
type: pure-token
52+
- name: countNaN
53+
since: 8.6.0
54+
token: COUNTNAN
55+
type: pure-token
56+
- name: countAll
57+
since: 8.6.0
58+
token: COUNTALL
59+
type: pure-token
5260
name: aggregator
5361
token: AGGREGATION
5462
type: oneof
@@ -69,7 +77,7 @@ categories:
6977
- kubernetes
7078
- clients
7179
complexity: O(1)
72-
description: Create a compaction rule
80+
description: Create a compaction rule. Starting from Redis 8.6, aggregation functions ignore NaN values when computing compacted results.
7381
group: timeseries
7482
hidden: false
7583
linkTitle: TS.CREATERULE
@@ -110,19 +118,21 @@ aggregates results into time buckets.
110118

111119
| `aggregator` | Description |
112120
| ------------ | ------------------------------------------------------------------------------ |
113-
| `avg` | Arithmetic mean of all values |
114-
| `sum` | Sum of all values |
115-
| `min` | Minimum value |
116-
| `max` | Maximum value |
117-
| `range` | Difference between the highest and the lowest value |
118-
| `count` | Number of values |
119-
| `first` | Value with lowest timestamp in the bucket |
120-
| `last` | Value with highest timestamp in the bucket |
121-
| `std.p` | Population standard deviation of the values |
122-
| `std.s` | Sample standard deviation of the values |
123-
| `var.p` | Population variance of the values |
124-
| `var.s` | Sample variance of the values |
125-
| `twa` | Time-weighted average over the bucket's timeframe (since RedisTimeSeries v1.8) |
121+
| `avg` | Arithmetic mean of all non-NaN values (ignores NaN values since Redis 8.6) |
122+
| `sum` | Sum of all non-NaN values (ignores NaN values since Redis 8.6) |
123+
| `min` | Minimum non-NaN value (ignores NaN values since Redis 8.6) |
124+
| `max` | Maximum non-NaN value (ignores NaN values since Redis 8.6) |
125+
| `range` | Difference between the highest and the lowest non-NaN value (ignores NaN values since Redis 8.6) |
126+
| `count` | Number of non-NaN values (ignores NaN values since Redis 8.6) |
127+
| `countNaN` | Number of NaN values (since Redis 8.6) |
128+
| `countAll` | Number of all values, both NaN and non-NaN (since Redis 8.6) |
129+
| `first` | Value with lowest timestamp in the bucket (ignores NaN values since Redis 8.6) |
130+
| `last` | Value with highest timestamp in the bucket (ignores NaN values since Redis 8.6) |
131+
| `std.p` | Population standard deviation of the non-NaN values (ignores NaN values since Redis 8.6) |
132+
| `std.s` | Sample standard deviation of the non-NaN values (ignores NaN values since Redis 8.6) |
133+
| `var.p` | Population variance of the non-NaN values (ignores NaN values since Redis 8.6) |
134+
| `var.s` | Sample variance of the non-NaN values (ignores NaN values since Redis 8.6) |
135+
| `twa` | Time-weighted average over the bucket's timeframe (ignores NaN values since Redis 8.6) |
126136

127137
- `bucketDuration` is duration of each bucket, in milliseconds.
128138

content/commands/ts.decrby.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ is key name for the time series.
112112

113113
<details open><summary><code>subtrahend</code></summary>
114114

115-
is numeric value of the subtrahend (double).
115+
is numeric value of the subtrahend (double). Starting from Redis 8.6, an error is returned if the subtrahend is NaN.
116116
</details>
117117

118118
<note><b>Notes</b>
@@ -133,8 +133,10 @@ Unix time is the number of milliseconds that have elapsed since 00:00:00 UTC on
133133
`timestamp` must be equal to or higher than the maximum existing timestamp. When equal, the value of the sample with the maximum existing timestamp is decreased. If it is higher, a new sample with a timestamp set to `timestamp` is created, and its value is set to the value of the sample with the maximum existing timestamp minus `subtrahend`.
134134

135135
If the time series is empty, the value is set to `subtrahend`.
136-
136+
137137
When not specified, the timestamp is set to the Unix time of the server's clock.
138+
139+
<note><b>NaN Handling (Redis 8.6+):</b> An error is returned if the current value at the maximum existing timestamp is NaN.</note>
138140
</details>
139141

140142
<details open><summary><code>RETENTION retentionPeriod</code></summary>

content/commands/ts.get.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ syntax_fmt: TS.GET key [LATEST]
3434
title: TS.GET
3535
---
3636

37-
Get the sample with the highest timestamp from a given time series
37+
Get the sample with the highest timestamp from a given time series. Starting from Redis 8.6, NaN values are included in the results.
3838

3939
[Examples](#examples)
4040

content/commands/ts.incrby.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ is key name for the time series.
112112

113113
<details open><summary><code>addend</code></summary>
114114

115-
is numeric value of the addend (double).
115+
is numeric value of the addend (double). Starting from Redis 8.6, an error is returned if the addend is NaN.
116116
</details>
117117

118118
<note><b>Notes</b>
@@ -132,9 +132,11 @@ Unix time is the number of milliseconds that have elapsed since 00:00:00 UTC on
132132

133133
`timestamp` must be equal to or higher than the maximum existing timestamp. When equal, the value of the sample with the maximum existing timestamp is increased. If it is higher, a new sample with a timestamp set to `timestamp` is created, and its value is set to the value of the sample with the maximum existing timestamp plus `addend`.
134134

135-
If the time series is empty, the value is set to `addend`.
136-
135+
If the time series is empty, the value is set to `addend`.
136+
137137
When not specified, the timestamp is set to the Unix time of the server's clock.
138+
139+
<note><b>NaN Handling (Redis 8.6+):</b> An error is returned if the current value at the maximum existing timestamp is NaN.</note>
138140
</details>
139141

140142
<details open><summary><code>RETENTION retentionPeriod</code></summmary>

content/commands/ts.madd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Unix time is the number of milliseconds that have elapsed since 00:00:00 UTC on
6262
<details open>
6363
<summary><code>value</code></summary>
6464

65-
is numeric data value of the sample (double). The double number should follow <a href="https://tools.ietf.org/html/rfc7159">RFC 7159</a> (a JSON standard). The parser rejects overly large values that would not fit in binary64. It does not accept NaN or infinite values.
65+
is numeric data value of the sample (double). The double number should follow <a href="https://tools.ietf.org/html/rfc7159">RFC 7159</a> (a JSON standard). The parser rejects overly large values that would not fit in binary64. It does not accept infinite values. NaN (Not a Number) values are supported starting from Redis 8.6.
6666
</details>
6767

6868
<note><b>Notes:</b>

content/commands/ts.mget.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ syntax_fmt: "TS.MGET [LATEST] [WITHLABELS | SELECTED_LABELS label1 [label1 ...]]
7070
title: TS.MGET
7171
---
7272

73-
Get the sample with the highest timestamp from each time series matching a specific filter.
73+
Get the sample with the highest timestamp from each time series matching a specific filter. Starting from Redis 8.6, NaN values are included in the results.
7474

7575
{{< note >}}
7676
This command will reply only if the current user has read access to all keys that match the filter.

content/commands/ts.mrange.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ syntax_fmt: "TS.MRANGE fromTimestamp toTimestamp [LATEST] [FILTER_BY_TS\_Timesta
177177
title: TS.MRANGE
178178
---
179179

180-
Query a range across multiple time series by filters in the forward direction.
180+
Query a range across multiple time series by filters in the forward direction. Starting from Redis 8.6, NaN values are included in raw measurement reports (queries without aggregation).
181181

182182
{{< note >}}
183183
This command will reply only if the current user has read access to all keys that match the filter.
@@ -240,7 +240,7 @@ When used together with `AGGREGATION`: samples are filtered before being aggrega
240240
<details open>
241241
<summary><code>FILTER_BY_VALUE min max</code> (since RedisTimeSeries v1.6)</summary>
242242

243-
filters samples by minimum and maximum values.
243+
filters samples by minimum and maximum values. Starting from Redis 8.6, `min` and `max` cannot be NaN values.
244244

245245
When used together with `AGGREGATION`: samples are filtered before being aggregated.
246246
</details>
@@ -291,19 +291,21 @@ per time series, aggregates samples into time buckets, where:
291291

292292
| `aggregator` | Description |
293293
| ------------ | ------------------------------------------------------------------------------ |
294-
| `avg` | Arithmetic mean of all values |
295-
| `sum` | Sum of all values |
296-
| `min` | Minimum value |
297-
| `max` | Maximum value |
298-
| `range` | Difference between maximum value and minimum value |
299-
| `count` | Number of values |
300-
| `first` | Value with lowest timestamp in the bucket |
301-
| `last` | Value with highest timestamp in the bucket |
302-
| `std.p` | Population standard deviation of the values |
303-
| `std.s` | Sample standard deviation of the values |
304-
| `var.p` | Population variance of the values |
305-
| `var.s` | Sample variance of the values |
306-
| `twa` | Time-weighted average over the bucket's timeframe (since RedisTimeSeries v1.8) |
294+
| `avg` | Arithmetic mean of all non-NaN values (ignores NaN values since Redis 8.6) |
295+
| `sum` | Sum of all non-NaN values (ignores NaN values since Redis 8.6) |
296+
| `min` | Minimum non-NaN value (ignores NaN values since Redis 8.6) |
297+
| `max` | Maximum non-NaN value (ignores NaN values since Redis 8.6) |
298+
| `range` | Difference between maximum non-NaN value and minimum non-NaN value (ignores NaN values since Redis 8.6) |
299+
| `count` | Number of non-NaN values (ignores NaN values since Redis 8.6) |
300+
| `countNaN` | Number of NaN values (since Redis 8.6) |
301+
| `countAll` | Number of all values, both NaN and non-NaN (since Redis 8.6) |
302+
| `first` | Value with lowest timestamp in the bucket (ignores NaN values since Redis 8.6) |
303+
| `last` | Value with highest timestamp in the bucket (ignores NaN values since Redis 8.6) |
304+
| `std.p` | Population standard deviation of the non-NaN values (ignores NaN values since Redis 8.6) |
305+
| `std.s` | Sample standard deviation of the non-NaN values (ignores NaN values since Redis 8.6) |
306+
| `var.p` | Population variance of the non-NaN values (ignores NaN values since Redis 8.6) |
307+
| `var.s` | Sample variance of the non-NaN values (ignores NaN values since Redis 8.6) |
308+
| `twa` | Time-weighted average over the bucket's timeframe (ignores NaN values since Redis 8.6) |
307309

308310
- `bucketDuration` is duration of each bucket, in milliseconds.
309311

@@ -354,16 +356,18 @@ When combined with `AGGREGATION` the `GROUPBY`/`REDUCE` is applied post aggregat
354356

355357
| `reducer` | Description |
356358
| --------- | ----------------------------------------------------------------------------------------------- |
357-
| `avg` | Arithmetic mean of all non-NaN values (since RedisTimeSeries v1.8) |
358-
| `sum` | Sum of all non-NaN values |
359-
| `min` | Minimum non-NaN value |
360-
| `max` | Maximum non-NaN value |
361-
| `range` | Difference between maximum non-NaN value and minimum non-NaN value (since RedisTimeSeries v1.8) |
362-
| `count` | Number of non-NaN values (since RedisTimeSeries v1.8) |
363-
| `std.p` | Population standard deviation of all non-NaN values (since RedisTimeSeries v1.8) |
364-
| `std.s` | Sample standard deviation of all non-NaN values (since RedisTimeSeries v1.8) |
365-
| `var.p` | Population variance of all non-NaN values (since RedisTimeSeries v1.8) |
366-
| `var.s` | Sample variance of all non-NaN values (since RedisTimeSeries v1.8) |
359+
| `avg` | Arithmetic mean of all non-NaN values (ignores NaN values since Redis 8.6) |
360+
| `sum` | Sum of all non-NaN values (ignores NaN values since Redis 8.6) |
361+
| `min` | Minimum non-NaN value (ignores NaN values since Redis 8.6) |
362+
| `max` | Maximum non-NaN value (ignores NaN values since Redis 8.6) |
363+
| `range` | Difference between maximum non-NaN value and minimum non-NaN value (ignores NaN values since Redis 8.6) |
364+
| `count` | Number of non-NaN values (ignores NaN values since Redis 8.6) |
365+
| `countNaN`| Number of NaN values (since Redis 8.6) |
366+
| `countAll`| Number of all values, both NaN and non-NaN (since Redis 8.6) |
367+
| `std.p` | Population standard deviation of all non-NaN values (ignores NaN values since Redis 8.6) |
368+
| `std.s` | Sample standard deviation of all non-NaN values (ignores NaN values since Redis 8.6) |
369+
| `var.p` | Population variance of all non-NaN values (ignores NaN values since Redis 8.6) |
370+
| `var.s` | Sample variance of all non-NaN values (ignores NaN values since Redis 8.6) |
367371

368372
<note><b>Notes:</b>
369373
- The produced time series is named `<label>=<value>`

0 commit comments

Comments
 (0)