I’m slowly learning Flux and have bumped into an error I can’t resolve. I’m unsure if I’m misunderstanding the language itself, or if I’ve found a bug. My environment is InfluxCloud v2 Beta.
In short, an otherwise successful query produces a panic when I attempt to rewrite it as a function block. The raw, successful query is immediately below followed by my attempt at a function block version of it.
The function block produces this error: panic: column _value_reading:string is not of type float
.
Have I structured the function incorrectly? I can provide snippets of the relevant tables produced by the various statements if it’s helpful.
A handful of searches in the open issues for the Flux project in Github did not result in any obviously related bugs. Then again, I’m still learning the language and am quite unfamiliar with its inner workings.
Query
readings = from(bucket: "<bucket>")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "Air Temperature" and r._field == "Value")
|> filter(fn: (r) => r.Location == "<location>")
validities = from(bucket: "<bucket>")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "Air Temperature" and r._field == "Validity")
|> filter(fn: (r) => r.Location == "<location>")
|> group(columns: ["_value"])
|> filter(fn: (r) => r._value == "Good")
join(tables: {reading:readings, validity:validities},
on: ["_time", "_stop", "_start", "Location", "Source", "_measurement"])
Function Block
validReadings = (tables=<-, measurement, location, validity) => {
source = tables
|> filter(fn: (r) => r._measurement == measurement)
|> filter(fn: (r) => r.Location == location)
readings = source
|> filter(fn: (r) => r._field == "Value")
validities = source
|> filter(fn: (r) => r._field == "Validity")
|> group(columns: ["_value”])
|> filter(fn: (r) => r._value == validity)
return join(tables: {reading:readings, validity:validities},
on: ["_time", "_stop", "_start", "Location", "Source", "_measurement"])
}
from(bucket: "<bucket>")
|> range(start: -1h)
|> validReadings(measurement:"Air Temperature", location:"<location>", validity:"Good")