Search code examples
influxdbinfluxdb-2

What is the equivalent of SELECT <certain columns> in Flux Query Language?


What would be equivalent flux query for SELECT address, name FROM addresses ? (I am referring to FluxQL, the new query language developed by InfluxData)

I didn't find a clear answer to this in the limited Flux Documentation present. Flux documentation says that filter() function is the equivalent of both SELECT and WHERE clauses, but all examples given are equivalent of WHERE clauses, nothing on SELECT.

These are the documentation for FluxQL for better reference:

https://docs.influxdata.com/flux/v0.50/introduction/getting-started

https://v2.docs.influxdata.com/v2.0/query-data/get-started/


Solution

  • maybe you need something like this:

    filter(fn: (r) => r._measurement == "addresses" and (r._field == "address" or r._field == "name"))
    |> pivot(rowKey:["_time"], columnKey:["_field"], valueColumn:"_value")
    |> drop(columns:["_value", ...])
    

    in the "drop" (instead of ...) you can list all excesses columns