Hi, I am trying to filter my bucket based _field and _value as shown below. However, I get the following runtime error.
from(bucket: "main_bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "Events")
|> filter(fn: (r) => (
(r["_field"] == "Action" and r["_value"] == "HOME") or
(r["_field"] == "Timeout" and exists r["_value"])
))
runtime error @5:8-8:7: filter: cannot compile @ 5:19-8:6: unsupported binary expression float == string
In debugging, I have found that if I remove all data related to my CycleTime _field
from the bucket (in same measurement), whose _value
will always be a float type, the error will disappear. However, I see in the documentation that the exists
operator should work with floats as shown here: Work with null types | Flux Documentation. Regardless, since the exists
operator is called on the LH of the and
statement, should all _values
from that float field be omitted by short-circuit evaluation.
I have also tried wrapping my r[“_value”] in the string function to make sure it is string but I am getting the same error. ... and exists string(v: r["_value"])
Please let me know if you have any ideas, thank you in advance
Side Note: Originally, I did not require the exists
operator at all, however when I imported my bucket to local influxDB instance, I was getting odd results from the filtering where certain values would be omitted when I use the r[“_value”] == “HOME” which would not happen on cloud. I noticed local and cloud use different flux versions, could that be why?