Group by and fill(previous) creating wrong result

We are having some trouble with an influx query and are wondering if this is a bug or we are not using it correctly.
When we group by a time span and a tag and additionally use fill(previous) it will also backfill before the first datapoint and ignore the grouping. So our example is this:
This is the original data:
select * from event

name: event
time                           device sp
----                           ------ --
2019-04-05T09:40:28.530569396Z a      1
2019-04-05T09:40:36.792129892Z b      5

Then we run the following select:
select last(sp) from event where time>now()-15m group by time(1m),device fill(previous)

And get this result:

name: event
tags: device=a
time                 last
----                 ----
2019-04-05T09:40:00Z 1
2019-04-05T09:41:00Z 1
2019-04-05T09:42:00Z 1
2019-04-05T09:43:00Z 1
2019-04-05T09:44:00Z 1
2019-04-05T09:45:00Z 1
2019-04-05T09:46:00Z 1
2019-04-05T09:47:00Z 1
2019-04-05T09:48:00Z 1

name: event
tags: device=b
time                 last
----                 ----
2019-04-05T09:33:00Z 1
2019-04-05T09:34:00Z 1
2019-04-05T09:35:00Z 1
2019-04-05T09:36:00Z 1
2019-04-05T09:37:00Z 1
2019-04-05T09:38:00Z 1
2019-04-05T09:39:00Z 1
2019-04-05T09:40:00Z 5
2019-04-05T09:41:00Z 5
2019-04-05T09:42:00Z 5
2019-04-05T09:43:00Z 5
2019-04-05T09:44:00Z 5
2019-04-05T09:45:00Z 5
2019-04-05T09:46:00Z 5
2019-04-05T09:47:00Z 5
2019-04-05T09:48:00Z 5

We would expect the first 7 entries to be empty for both devices, as there is no data available before that time. Instead influx fills the empty data for the second device with values from the first. Reading the documentation we are not able to explain this behaviour. We would like the results to be the same for both devices. Does anybody have an idea what is going on?

1 Like

Nice find @Francisca this looks like a bug to me! I can confirm the same behavior on my machine running v1.7.5 RPM. Without the fill it does the right thing, showing the correct values. I think we should submit this in github!

It gets even more fun when you do this:

select last(sp) from event where time > now() - 15m group by time(1m),device fill(previous) order by desc


1 Like

I had the same issue with InfluxDB 1.7.6. I updated to 1.7.7 and it seems to work now. Does anyone know if this has been fixed? If so, feel free to close this issue Empty results of a nested query get filled with previous results · Issue #15830 · influxdata/influxdb · GitHub