influxdata / influxdb

Scalable datastore for metrics, events, and real-time analytics
https://influxdata.com
Apache License 2.0
28.36k stars 3.52k forks source link

Inconsistent output for weekly groupings with offset and timezone parameter during time change #19676

Open federicogatti opened 3 years ago

federicogatti commented 3 years ago

Steps to reproduce:

  1. Connect to Influx using -precision rfc339 option, like influx --database <database> --username <username> --password <password> -precision rfc3339
  2. Write a query that include a change hour from winter time to summer time grouping by week and starting from monday (4 days offset), for example with italian timezone:
    SELECT sum("value") FROM "datapoint_values" WHERE "plant"='0001' AND "datapoint"='PWER' AND time >= '2020-03-20T00:00:00Z' AND time <= '2020-04-30T00:00:00Z' GROUP BY time(1w,4d) fill(0) tz('Europe/Rome')

Expected behavior:

time                      sum
----                      ---
2020-03-16T00:00:00+01:00 882795
2020-03-23T00:00:00+01:00 818340
2020-03-30T00:00:00+02:00 713050
2020-04-06T00:00:00+02:00 477533
2020-04-13T00:00:00+02:00 418878
2020-04-20T00:00:00+02:00 424883
2020-04-27T00:00:00+02:00 187801

Actual behavior:

time                      sum
----                      ---
2020-03-16T00:00:00+01:00 882795
2020-03-23T00:00:00+01:00 818340
2020-03-30T00:00:00+02:00 0
2020-03-30T01:00:00+02:00 713050
2020-04-06T00:00:00+02:00 477533
2020-04-13T00:00:00+02:00 418878
2020-04-20T00:00:00+02:00 424883
2020-04-27T00:00:00+02:00 187801

An additional line with zero result is printed (2020-03-30T00:00:00+02:00 0), also one line time is not midnight located (2020-03-30T01:00:00+02:00 713050)

Additional info:

SELECT sum("value") FROM "datapoint_values" WHERE "plant"='0001' AND "datapoint"='PWER' AND time >= '2020-03-16T00:00:00Z' AND time <= '2020-04-30T00:00:00Z' GROUP BY time(1w,3d) fill(0) tz('Europe/Rome')
name: datapoint_values
time                      sum
----                      ---
2020-03-15T00:00:00+01:00 846944
2020-03-22T00:00:00+01:00 1100599
2020-03-29T00:00:00+01:00 712901
2020-04-05T00:00:00+02:00 496406
2020-04-12T00:00:00+02:00 417564
2020-04-19T00:00:00+02:00 424568
2020-04-26T00:00:00+02:00 247997

SELECT sum("value") FROM "datapoint_values" WHERE "plant"='0001' AND "datapoint"='PWER' AND time >= '2020-03-16T00:00:00Z' AND time <= '2020-04-30T00:00:00Z' GROUP BY time(1w) fill(0) tz('Europe/Rome')
name: datapoint_values
time                      sum
----                      ---
2020-03-12T00:00:00+01:00 243645
2020-03-19T00:00:00+01:00 1472722
2020-03-26T00:00:00+01:00 657964
2020-04-02T00:00:00+02:00 596316
2020-04-09T00:00:00+02:00 425270
2020-04-16T00:00:00+02:00 418544
2020-04-23T00:00:00+02:00 427514
2020-04-30T00:00:00+02:00 5004

Environment info:

same behavior with updated version InfluxDB v1.8.3 (git: 1.8 563e6c3d1a7a2790763c6289501095dbec19244e)

federicogatti commented 3 years ago

Hi, any news about this issue?

federicogatti commented 2 years ago

Hi, this bug still remains with a change of the output. Now there isn't an additional line, but the result of the week where the time change is always 0

SELECT sum("value") FROM "datapoint_values" WHERE "plant"='0001' AND "datapoint"='PWER' AND time >= '2020-03-20T00:00:00Z' AND time <= '2020-04-30T00:00:00Z' GROUP BY time(1w,4d) fill(0) tz('Europe/Rome')
name: datapoint_values
time                      sum
----                      ---
2020-03-16T00:00:00+01:00 882795
2020-03-23T00:00:00+01:00 1531390
2020-03-30T00:00:00+02:00 0
2020-04-06T00:00:00+02:00 477533
2020-04-13T00:00:00+02:00 418878
2020-04-20T00:00:00+02:00 424883
2020-04-27T00:00:00+02:00 187801