How to resolve filter by multi columns query error?

line protocol:

<measurement>,device_id=1,data_point_id=1 value=100
<measurement>,device_id=1,data_point_id=1 value=100
<measurement>,device_id=1,data_point_id=2 value=100
<measurement>,device_id=1,data_point_id=2 value=100

<measurement>,device_id=2,data_point_id=1 value=100
<measurement>,device_id=2,data_point_id=1 value=100
<measurement>,device_id=2,data_point_id=2 value=100
<measurement>,device_id=2,data_point_id=2 value=100

After data insert success. I want to query data which device_id, data_point_id in an array dict:

arr = [
    {device_id: "1", data_point_id: "1"},
    {device_id: "2", data_point_id: "2"},
]

So I wrote a function:

isFit = (device_id, data_point_id) => {
    r = arr |> findRecord(fn: (key) => key.device_id == device_id and key.data_point_id == data_point_id, idx: 0)
    return exists r
}

The whole Flux script like this:

import "dict"
import "array"

arr = [
    {device_id: "1", data_point_id: "1"},
    {device_id: "2", data_point_id: "2"},
]

isFit = (device_id, data_point_id) => {
    r = arr |> findRecord(fn: (key) => key.device_id == device_id and key.data_point_id == data_point_id, idx: 0)
    return exists r
}

from(bucket: "<bucket>")  
    |> range(start: 2023-04-23T08:51:54.661Z) 
    |> filter(fn: (r) => r["_measurement"] == "<measurement>") 
    |> filter(fn: (r) => isFit(device_id: r["device_id"], data_point_id: r["data_point_id"])
)

When I run the script, I got the follow error:

error @7:9-7:12: expected stream[{device_id: string, data_point_id: string}] but found [{device_id: string, data_point_id: string}] (array) (argument tables)

I’m a newbie in InfluxdDB and Flux Query Language, So this problem may be so easy to resolve. Could any master tell me how to fix this error. Thanks!!!

Hello @honorfight,
You can’t apply findRecord() on an array. Only on a table stream/query on influxDB data. (i.e from() |> range()) .

You might want to check out this documentation to understand how you can work with arrays with Flux: