docs-v2/content/flux/v0.x/stdlib/universe/first.md

1.7 KiB
Raw Permalink Blame History

title description aliases menu weight flux/v0.x/tags related introduced
first() function The `first()` function selects the first non-null record from an input table.
/influxdb/v2.0/reference/flux/functions/transformations/selectors/first
/influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/first/
/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/first/
/influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/first/
flux_0_x_ref
name parent
first universe
102
selectors
transformations
/{{< latest "influxdb" >}}/query-data/flux/first-last/
/{{< latest "influxdb" "v1" >}}/query_language/functions/#first, InfluxQL  FIRST()
0.7.0

The first() function selects the first non-null record from an input table. first() is a selector function.

first()

{{% warn %}}

Empty tables

first() drops empty tables. {{% /warn %}}

Parameters

tables

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

Examples

{{% flux/sample-example-intro %}}

import "sampledata"

sampledata.int()
    |> first()

{{% expand "View input and output" %}} {{< flex >}} {{% flex-content %}}

Input data

{{% flux/sample "int" %}}

{{% /flex-content %}} {{% flex-content %}}

Output data
_time tag _value
2021-01-01T00:00:00Z t1 -2
_time tag _value
2021-01-01T00:00:00Z t2 19

{{% /flex-content %}} {{< /flex >}} {{% /expand %}}