Back to Influxdb

experimental.fill() function

content/flux/v0/stdlib/experimental/fill.md

latest4.8 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/experimental/experimental.flux#L1091-L1095 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

experimental.fill() replaces all null values in the _value column with a non-null value.

Function type signature
js
(<-tables: stream[{B with _value: A}], ?usePrevious: bool, ?value: A) => stream[{B with _value: A}]

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

value

Value to replace null values with. Data type must match the type of the _value column.

usePrevious

Replace null values with the value of the previous non-null row.

tables

Input data. Default is piped-forward data (<-).

Examples

Fill null values with a specified non-null value

js
import "experimental"
import "sampledata"

sampledata.int(includeNull: true)
    |> experimental.fill(value: 0)

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time_value*tag
2021-01-01T00:00:00Z-2t1
2021-01-01T00:00:10Zt1
2021-01-01T00:00:20Z7t1
2021-01-01T00:00:30Zt1
2021-01-01T00:00:40Zt1
2021-01-01T00:00:50Z4t1
_time_value*tag
2021-01-01T00:00:00Zt2
2021-01-01T00:00:10Z4t2
2021-01-01T00:00:20Z-3t2
2021-01-01T00:00:30Z19t2
2021-01-01T00:00:40Zt2
2021-01-01T00:00:50Z1t2

Output data

_time_value*tag
2021-01-01T00:00:00Z-2t1
2021-01-01T00:00:10Z0t1
2021-01-01T00:00:20Z7t1
2021-01-01T00:00:30Z0t1
2021-01-01T00:00:40Z0t1
2021-01-01T00:00:50Z4t1
_time_value*tag
2021-01-01T00:00:00Z0t2
2021-01-01T00:00:10Z4t2
2021-01-01T00:00:20Z-3t2
2021-01-01T00:00:30Z19t2
2021-01-01T00:00:40Z0t2
2021-01-01T00:00:50Z1t2

{{% /expand %}} {{< /expand-wrapper >}}

Fill null values with the previous non-null value

js
import "experimental"
import "sampledata"

sampledata.int(includeNull: true)
    |> experimental.fill(usePrevious: true)

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time_value*tag
2021-01-01T00:00:00Z-2t1
2021-01-01T00:00:10Zt1
2021-01-01T00:00:20Z7t1
2021-01-01T00:00:30Zt1
2021-01-01T00:00:40Zt1
2021-01-01T00:00:50Z4t1
_time_value*tag
2021-01-01T00:00:00Zt2
2021-01-01T00:00:10Z4t2
2021-01-01T00:00:20Z-3t2
2021-01-01T00:00:30Z19t2
2021-01-01T00:00:40Zt2
2021-01-01T00:00:50Z1t2

Output data

_time_value*tag
2021-01-01T00:00:00Z-2t1
2021-01-01T00:00:10Z-2t1
2021-01-01T00:00:20Z7t1
2021-01-01T00:00:30Z7t1
2021-01-01T00:00:40Z7t1
2021-01-01T00:00:50Z4t1
_time_value*tag
2021-01-01T00:00:00Zt2
2021-01-01T00:00:10Z4t2
2021-01-01T00:00:20Z-3t2
2021-01-01T00:00:30Z19t2
2021-01-01T00:00:40Z19t2
2021-01-01T00:00:50Z1t2

{{% /expand %}} {{< /expand-wrapper >}}