influxdata / influxdata/influxdb

Subquery with fill(previous) unexpected behaviour

Open
#9,317 16 comments 8 reactions 1 assignee Claimed by @psteinbachs View on GitHub
1.x area/queries kind/bug pm/consumability
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

### Bug report

__System info:__
InfluxDB v1.4.2
CentOS Linux release 7.4.1708

__Steps to reproduce:__

1. I have a Influxdb table where I store (among other data) the state of many VPSs, ir can be running, suspended or stopped, and the VPSs are identified by id as a tag, I want to know the total number of VPSs in each state.
2. The query:
`SELECT last("status") AS "status" FROM "tbh_vps"."autogen"."general" WHERE time > now() - 5m AND ("id"='22' OR "id"='41') GROUP BY time(30s), "id" FILL(previous)`
Returns the last 11 states of that 2 VPSs and I use fill(previous) because I gather data every 30 seconds and if I run te query after the node has sent the data the last state appears as null.
3. As I want the count and not individual states I use the last query as a subquery on:
`SELECT count("status") FROM (SUBQUERIE) WHERE "status" = 'running' group by time(30s)`

__Expected behavior:__
I expect to return something like:

time count
01/15/18 04:22:30PM 2
01/15/18 04:23:00PM 2
01/15/18 04:23:30PM 2
01/15/18 04:24:00PM 2
01/15/18 04:24:30PM 2
01/15/18 04:25:00PM 2
01/15/18 04:25:30PM 2
01/15/18 04:26:00PM 2
01/15/18 04:26:30PM 2
01/15/18 04:27:00PM 2

__Actual behavior:__

It returns:

time count
1/15/2018 4:25:00 PM 1
1/15/2018 4:25:30 PM 1
1/15/2018 4:26:00 PM 1
1/15/2018 4:26:30 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:25:00 PM 1
1/15/2018 4:25:30 PM 1
1/15/2018 4:26:00 PM 1
1/15/2018 4:26:30 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:25:30 PM 1
1/15/2018 4:26:00 PM 1
1/15/2018 4:26:30 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:25:30 PM 1
1/15/2018 4:26:00 PM 1
1/15/2018 4:26:30 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:26:00 PM 1
1/15/2018 4:26:30 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:26:00 PM 1
1/15/2018 4:26:30 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:26:30 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:26:30 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:27:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:27:30 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:28:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:28:30 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:29:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1
1/15/2018 4:29:30 PM 1
1/15/2018 4:30:00 PM 1

Actually the only diference between the expected behavior and the actual behavior if that if I do not include the fill(previous) in the subquery it works as expected so I suppose there is a problem with the fill(previous) behaviour inside subqueries.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.