keys() function
keys()
returns the columns that are in the group key of each input table.
Each output table contains a row for each group key column label.
A single group key column label is stored in the specified column
for each row.
All columns not in the group key are dropped.
Function type signature
(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record
Parameters
column
Column to store group key labels in. Default is _value
.
tables
Input data. Default is piped-forward data (<-
).
Examples
- Return group key columns for each input table
- Return all distinct group key columns in a single table
- Return group key columns as an array
Return group key columns for each input table
data
|> keys()
Return all distinct group key columns in a single table
data
|> keys()
|> keep(columns: ["_value"])
|> distinct()
Return group key columns as an array
- Use
keys()
to replace the_value
column with the group key labels. - Use
findColumn()
to return the_value
column as an array.
import "sampledata"
sampledata.int()
|> keys()
|> findColumn(fn: (key) => true, column: "_value")// Returns [tag]
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.