redisredistimeseries

RedisTimeSeries TS.RANGE returns timestamps in the past


I have the following RedisTimeSeries key:

127.0.0.1:6379> ts.info ts_raw_l:TSLA
 1) totalSamples
 2) (integer) 771
 3) memoryUsage
 4) (integer) 8416
 5) firstTimestamp
 6) (integer) 1546405200000
 7) lastTimestamp
 8) (integer) 1642741200000
 9) retentionTime
10) (integer) 0
11) chunkCount
12) (integer) 2
13) chunkSize
14) (integer) 4096
15) chunkType
16) compressed
17) duplicatePolicy
18) (nil)
19) labels
20) (empty array)
21) sourceKey
22) (nil)
23) rules
24) 1) 1) "ts_agg_y_l:TSLA"
       2) (integer) 31556952000
       3) MIN
127.0.0.1:6379>

I have a range query where fromTimestamp and toTimestamp represent a time period of 5 business days.

127.0.0.1:6379> ts.range ts_raw_l:TSLA 1641790800000 1642222799000
1) 1) (integer) 1641790800000
   2) 980
2) 1) (integer) 1641877200000
   2) 1038.82
3) 1) (integer) 1641963600000
   2) 1072.5901
4) 1) (integer) 1642050000000
   2) 1026.5391
5) 1) (integer) 1642136400000
   2) 1013.3788
127.0.0.1:6379>

I apply a min aggregation filter to this range with a timeBucket value of 5 days and align it with fromTimestamp:

127.0.0.1:6379> TS.RANGE ts_raw_l:TSLA 1641790800000 1642222799000 ALIGN 1641790800000 AGGREGATION min 432000000
1) 1) (integer) 1641600000000
   2) 980
2) 1) (integer) 1642032000000
   2) 1013.3788
127.0.0.1:6379> 

I would expect one result, 980 and I would expect the timestamp of that result to be within the fromTimestamp and toTimestamp ranges provided in the query.

Why do I get two results? And, why is 980 returned with a timestamp that is earlier than fromTimestamp?

Redis/module versions:

127.0.0.1:6379> MODULE LIST
1) 1) "name"
   2) "bf"
   3) "ver"
   4) (integer) 20206
2) 1) "name"
   2) "ai"
   3) "ver"
   4) (integer) 10205
3) 1) "name"
   2) "timeseries"
   3) "ver"
   4) (integer) 10410
4) 1) "name"
   2) "rg"
   3) "ver"
   4) (integer) 10008
5) 1) "name"
   2) "graph"
   3) "ver"
   4) (integer) 20411
6) 1) "name"
   2) "ReJSON"
   3) "ver"
   4) (integer) 20004
7) 1) "name"
   2) "search"
   3) "ver"
   4) (integer) 20205
127.0.0.1:6379> 

Solution

  • This feature is supported in master and 1.6 (or newer) versions. Make sure you use a newer version of RedisTimeSeries.