fill() function
The fill()
function replaces all null values in an input stream with a non-null value. The output stream is the same as the input stream with all null values replaced in the specified column.
*Function type: Transformation*
fill(column: "_value", value: 0.0)
// OR
fill(column: "_value", usePrevious: true)
Parameters
column
The column in which to replace null values. Defaults to "_value"
.
*Data type: String*
value
The constant value to use in place of nulls. The value type must match the value type of the column
.
*Data type: Boolean | Integer | UInteger | Float | String | Time | Duration*
usePrevious
When true
, assigns the value set in the previous non-null row.
Cannot be used with value
.
*Data type: Boolean*
Examples
Fill null values with a specified non-null value
from(bucket: "example-bucket")
|> range(start: -1h)
|> filter(fn: (r) =>
r._measurement == "cpu" and
r.cpu == "cpu-total"
)
|> fill(value: 0.0)
Fill null values with the previous non-null value
from(bucket: "example-bucket")
|> range(start: -1h)
|> filter(fn: (r) =>
r._measurement == "cpu" and
r.cpu == "cpu-total"
)
|> fill(usePrevious: true)