influxdbinfluxql

SELECT * FROM x WHERE CONDITION equivalent in FLUXQuery


I'm trying the following simple query that in SQL would look like this:

SELECT * 
FROM MEASUREMENT 
WHERE end_date > 1687447435983242

I want the equivalent of this in FluxQuey. So far I have achieved:

from(bucket: "some_bucket")
|> range(start: 0)
|> filter(fn: (r) => r._measurement == "MEASUREMENT"  and r._field == "end_date" and r._value >= 1687447435983242)
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")

However this is equivalent to:

SELECT end_date 
FROM MEASUREMENT 
WHERE end_date > 1687447435983242

I want to get all the fields from the measurement, not just "end_date"


Solution

  • Filter by measurement, construct table, and filter by field in table.

    from(bucket: "some_bucket")
    |> range(start: 0)
    |> filter(fn: (r) => r._measurement == "MEASUREMENT")
    |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
    |> filter(fn: (r) => r.end_date >= 1687447435983242)