To specify a default handling for values within queries, see the documentation.
The FILL
keyword expects a single fillOption
strategy which will be applied to each aggregate column. The following restrictions apply:
fillOption | Description |
---|---|
NONE | No fill applied. If there is no data, the time chunk will be skipped in the results. This means your table could potentially be missing intervals. |
Fills with NULL | |
PREV | Fills using the previous value |
LINEAR | Fills by linear interpolation of the 2 surrounding points |
x | Fills with a constant value - where x is the desired value, for example FILL(100.05) |
Examples
Consider an example table named prices
which has no records during the entire third hour ():
ts | price |
---|---|
2021-01-01T10:00:00.000000Z | p1 |
2021-01-01T11:00:00.000000Z | p2 |
2021-01-01T12:00:00.000000Z | p3 |
2021-01-01T14:00:00.000000Z | p4 |
2021-01-01T15:00:00.000000Z | p5 |
… | … |
The returned results look like this:
As there are missing values, an average aggregate cannot be calculated for the missing hour:
ts | min | max | average |
---|---|---|---|
2021-01-01T10:00:00.000000Z | min1 | max1 | avg1 |
2021-01-01T11:00:00.000000Z | min2 | max2 | avg2 |
2021-01-01T12:00:00.000000Z | min3 | max3 | avg3 |
2021-01-01T14:00:00.000000Z | min5 | max5 | avg5 |
Based on this example, a FILL
strategy can be employed which fills with the previous value using PREV
:
This query returns the following results where the fourth row is created by using the FILL
keyword:
ts | min | max | average |
---|---|---|---|
2021-01-01T10:00:00.000000Z | min1 | max1 | avg1 |
2021-01-01T11:00:00.000000Z | min2 | max2 | avg2 |
2021-01-01T12:00:00.000000Z | min3 | max3 | avg3 |
2021-01-01T13:00:00.000000Z | min3 | max3 | avg3 |
2021-01-01T14:00:00.000000Z | min5 | max5 | avg5 |
The results of this query look like the following:
This query demonstrates using a constant value as a fillOption
. If a constant value is used as a fillOption
, a value must be specified for each aggregate column:
The results of this query look like the following:
ts | min | max | average |
---|---|---|---|
2021-01-01T10:00:00.000000Z | min1 | max1 | avg1 |
2021-01-01T11:00:00.000000Z | min2 | max2 | avg2 |
2021-01-01T12:00:00.000000Z | min3 | max3 | avg3 |
2021-01-01T13:00:00.000000Z | 100.5 | 10 | 1 |
2021-01-01T14:00:00.000000Z | min5 | max5 | avg5 |
This query demonstrates using NULL
as a :
ts | min | max | average |
---|---|---|---|
2021-01-01T10:00:00.000000Z | min1 | max1 | avg1 |
2021-01-01T11:00:00.000000Z | min2 | max2 | avg2 |
2021-01-01T12:00:00.000000Z | min3 | max3 | avg3 |
2021-01-01T13:00:00.000000Z | null | null | null |
2021-01-01T14:00:00.000000Z | min5 | max5 | avg5 |