Parameterize access to Record object

Hi there,

We’re all know access to a record, such as:

filter(fn: (r) => r["_field"] == "abc")

Can we do something like this?

p = "_field"
filter(fn: (r) => r[p] == "abc")

Hello @Nam_Giang,
Unfortunately not yet, but will be soon!

As of Flux 0.134.0, there is a way to do this, so depending on which version of InfluxDB you’re using, it may be available to you. It’s the experimental record.get() function. It would look something like this:

import "experimental/record"

p = "_field"

// ...
    |> filter(fn: (r) => record.get(r: r, key: p, default: "example-default-value") == "abc")