influxdata / flux

Flux is a lightweight scripting language for querying databases (like InfluxDB) and working with data. It's part of InfluxDB 1.7 and 2.0, but can be run independently of those.
https://influxdata.com
MIT License
763 stars 152 forks source link

window produces confusing behavior when _time not in [_start, _stop) #2172

Closed wolffcm closed 3 months ago

wolffcm commented 4 years ago

In this example I range over the result produced by the given CSV and then update _time so that its outside of [_start, _stop).

import "csv"
import "experimental"

data = "
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#group,false,false,true,true,false,false,true,true,true,true
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,tag1,tag2
,,0,2019-09-20T13:50:00Z,2019-09-20T14:00:00Z,2019-09-20T13:59:00Z,0.016666666666666666,fld,ms,v1,tv2
"

csv.from(csv: data)
|> range(start: 2019-09-20T13:50:00Z, stop: 2019-09-20T14:00:00Z)
|> experimental.set(o: {_time: 2019-09-20T14:00:00Z})
|> window(every: 5m)

This is the result that is produced:

#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#group,false,false,true,true,false,false,true,true,true,true
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,tag1,tag2
,,0,2019-09-20T13:50:00Z,2019-09-20T13:50:00Z,2019-09-20T14:00:00Z,0.016666666666666666,fld,ms,v1,tv2

Note that _start and _stop are both set to the range's start time. This is seems incorrect and confusing.

It would be better to:

A user hit this issue in 1.7.9 where this related issue is not yet fixed: https://github.com/influxdata/influxdb/pull/14262

Also related: https://github.com/influxdata/flux/issues/2170

github-actions[bot] commented 3 months ago

This issue has had no recent activity and will be closed soon.