influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

Possible bug in CUMULATIVE_SUM function

Open sebastienfouss opened this issue 9 years ago • 1 comments

Bug report

System info: InfluxDB 1.2

Steps to reproduce:

Execute a CUMULATIVE_SUM query, for example:

select CUMULATIVE_SUM("value") from "hourly" where "deviceId" = 'XXX' and "time" <= 1493589599728000000 and "time" >= 1490997600000000000

name: hourly time cumulative_sum


1490997600000000000 433 [SNIP] 1491170400000000000 31677 1491174000000000000 32043 // OK until now 1491782400000000000 32360 // Here, timestamp jumps by 7 days, cumulative_sum is as expected 1491786000000000000 32703 1491789600000000000 33030 [SNIP] 1491937200000000000 59838 1491177600000000000 60141 // Timestamp jumps back by 7 days, cumulative_sum is as expected 1491181200000000000 60467 1491184800000000000 60744 1491188400000000000 61068 [SNIP] 1491775200000000000 141810 1491778800000000000 142144

To summarize,

  • the cumulative_sum seems correct (ie it increases from T0 until Tn)
  • however, after some time, the timestamps seem mixed up, instead of having: T0 T1 T2 T3 T4 T5 T6 T7 T8 ... Tn We see: T0 T1 T8 T9 ... Tn T2 T3 ... T7

WORKAROUND: Replace: select CUMULATIVE_SUM("value") from "hourly" where "deviceId" = 'XXX' and "time" <= 1493589599193000000 and "time" >= 1490997600000000000

By: select CUMULATIVE_SUM(MEAN("value")) from "hourly" where "deviceId" = 'XXX' and "time" <= 1493589599193000000 and "time" >= 1490997600000000000 group by time(1m)

sebastienfouss avatar Apr 11 '17 19:04 sebastienfouss

I think this is a duplicate of #8175. Can you try that out and see if it fixes your issue? If it doesn't, please respond here and I'll reopen this issue.

jsternberg avatar Apr 14 '17 19:04 jsternberg