Unsupported _field predicate

Hello!
I have a user of my android app that reported problems when updating fields.
I’m using influxdb-client-java:6.4.0.
The query is for example like this:
from(bucket: “HC3”) |> range(start: 1686295275, stop: 1686295997) |> filter(fn: (r) => r.deviceID == “224” and r.unit == “°C” and r._field == “value” or r.deviceID == “228” and r.unit == “°C” and r._field == “value” or r.deviceID == “180” and r.unit == “°C” and r._field == “value”)

Then the response:
com.influxdb.exceptions.BadRequestException: HTTP status code: 400; Message: Error creating series plans for namespace ‘32d1e4fdd1bd42ea_8680e907b5fce791’: read_filter: gRPC planner got error creating predicates: Error during planning: Unsupported _field predicate: CASE WHEN deviceID IS NULL THEN Utf8(“”) ELSE deviceID END = Utf8(“224”) AND CASE WHEN unit IS NULL THEN Utf8(“”) ELSE unit END = Utf8(“°C”) AND _field = Utf8(“value”) OR CASE WHEN deviceID IS NULL THEN Utf8(“”) ELSE deviceID END = Utf8(“228”) AND CASE WHEN unit IS NULL THEN Utf8(“”) ELSE unit END = Utf8(“°C”) AND _field = Utf8(“value”) OR CASE WHEN deviceID IS NULL THEN Utf8(“”) ELSE deviceID END = Utf8(“180”) AND CASE WHEN unit IS NULL THEN Utf8(“”) ELSE unit END = Utf8(“°C”) AND _field = Utf8(“value”)
caused by
Error during planning: Unsupported _field predicate: CASE WHEN deviceID IS NULL THEN Utf8(“”) ELSE deviceID END = Utf8(“224”) AND CASE WHEN unit IS NULL THEN Utf8(“”) ELSE unit END = Utf8(“°C”) AND _field = Utf8(“value”) OR CASE WHEN deviceID IS NULL THEN Utf8(“”) ELSE deviceID END = Utf8(“228”) AND CASE WHEN unit IS NULL THEN Utf8(“”) ELSE unit END = Utf8(“°C”) AND _field = Utf8(“value”) OR CASE WHEN deviceID IS NULL THEN Utf8(“”) ELSE deviceID END = Utf8(“180”) AND CASE WHEN unit IS NULL THEN Utf8(“”) ELSE unit END = Utf8(“°C”) AND _field = Utf8(“value”)

When querying a single field it works fine from his database.
Could anybody point me in the right direction?

Thanks!
Magnus

Hello @mlundell,
that’s super strange. I don’t know that I’ve seen that error before.
wait nvm i see the issue…typing my thoughts right now lol

My guess is maybe something with the and statements?
Like maybe there are instances where you have points that dont contain that device id, unit, and value for multiple devices?

I’d try using all or statements instead of and statements. Or multiple filters

from(bucket: “HC3”) |> range(start: 1686295275, stop: 1686295997) 
|> filter(fn: (r) => r.deviceID == “224” and r.unit == “°C” 
|> yield(name: "224") 

from(bucket: “HC3”) |> range(start: 1686295275, stop: 1686295997) 
 |> filter(fn: (r) => r._field == “value” or r.deviceID == “228” and r.unit == “°C”) 
|> yield(name: "228") 

from(bucket: “HC3”) |> range(start: 1686295275, stop: 1686295997) 
 |> filter(fn: (r) => r._field == “value” or r.deviceID == “180” and r.unit == “°C”)
|> yield(name: "180") 

Also make sure that you replace your quotes with straight quotes instead of curly
"
not

Thanks Anaisdg for taking your time to answer!

I will try!

I realized I have not told you how it went.
Thanks for your help Anaisdg, I followed your advice and it worked!

Example below:

from(bucket: “HC3L”) |> range(start: 1688312102, stop: 1688312996)
|> filter(fn: (r) => r.deviceID == “644” and r.roomName == “Aussen Ost” and r._field == “value”)
|> yield(name: “num_0”)
from(bucket: “HC3L”) |> range(start: 1688312102, stop: 1688312996)
|> filter(fn: (r) => r.deviceID == “913” and r._field == “value”)
|> yield(name: “num_1”)
from(bucket: “HC3L”) |> range(start: 1688312102, stop: 1688312996)
|> filter(fn: (r) => r._measurement == “climate” and r._field == “value” and r.deviceID == “913”)
|> yield(name: “num_2”)