ypnos
1
I don’t understand the observed behavior with Influx 2.6.1.
This query also returns 5 rows with column “_value”:
from(bucket: "halfyear")
|> range(start: -2m) // we know that data is flushed per-minute
|> filter(fn: (r) => r["_measurement"] == "deviceStatus")
|> keep(columns: ["_value"])
|> yield(name: "network")
This query also returns 5 rows, with columns “name”, “_value”, and “_time”:
from(bucket: "halfyear")
|> range(start: -2m) // we know that data is flushed per-minute
|> filter(fn: (r) => r["_measurement"] == "deviceStatus")
|> map(fn: (r) => ({ name: "Device", _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error", _time: r._time }))
|> yield(name: "network")
This query returns no result!
from(bucket: "halfyear")
|> range(start: -2m) // we know that data is flushed per-minute
|> filter(fn: (r) => r["_measurement"] == "deviceStatus")
|> map(fn: (r) => ({ name: "Device", _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error" }))
|> yield(name: "network")
The only difference is that we omit _time column because it is not needed.
Is this a bug or expected behavior?
Thanks!
Hello @ypnos,
Hmmmm wtf that makes no sense.
Weird…can you please create an issue?
Out of curiosity does this work?
from(bucket: "halfyear")
|> range(start: -2m) // we know that data is flushed per-minute
|> filter(fn: (r) => r["_measurement"] == "deviceStatus")
|> map(fn: (r) => ({ name: "Device"}))
|> map(fn: (r) => ({ _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error"}))
|> map(fn: (r) => ({ _time: r._time }))
|> yield(name: "network")
Maybe try commenting out each column respectively to try and find the culprit?
Thank you
ypnos
3
Only this version produces results:
from(bucket: "halfyear")
|> range(start: -2m) // we know that data is flushed per-minute
|> filter(fn: (r) => r["_measurement"] == "deviceStatus")
//|> map(fn: (r) => ({ name: "Device"}))
//|> map(fn: (r) => ({ _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error"}))
|> map(fn: (r) => ({ _time: r._time }))
|> yield(name: "network")
It appears like it really hates a row out of a map() without _time. While it is o.k. to get rid of _time via keep(). So this also works:
from(bucket: "halfyear")
|> range(start: -2m) // we know that data is flushed per-minute
|> filter(fn: (r) => r["_measurement"] == "deviceStatus")
//|> map(fn: (r) => ({ name: "Device"}))
//|> map(fn: (r) => ({ _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error"}))
|> map(fn: (r) => ({ _time: r._time, name: "Device" }))
|> keep(columns: ["name"])
|> yield(name: "network")
I will file a bug report.
scott
4
@ypnos, Where are you running the queries? In the Data Explorer?