flux
flux copied to clipboard
Cannot index a returned array while inside map.
data |> map(fn: (r) => ({_value: strings.split(v: r._value, t: "")[0]})) returns Error: cannot compile polymorphic function: type variable "t79" is not monomorphic
strings.split(v: "hai", t: "") works perfectly fine and returns [h, a, i]
strings.split(v: "hai", t: "")[1] works perfectly fine and returns a
I see this is quite an old bug but is anyone aware of any solution or workaround to this? I have two measurements, one is tagged with the human-readable last 5 digits of a serialnumber and the other is tagged with the full serialnumber. I'm preparing to use them both in a join by using;
map(fn: (r) => ({ r with suffix: strings.sub(v: r.serialnumber, start: -5, end: -1) }))
but getting
cannot compile polymorphic function: type variable \\"t78\\" is not monomorphic"
@andhya Try this:
// ...
|> map(
fn: (r) => {
length = strings.strlen(v: r.serialnumber)
suffix = strings.substring(v: r.serialnumber, start: length - 5, end: length)
return {r with suffix: suffix}
},
)
Thanks @sanderson , unfortunately that gives a subtly different but similar error;
cannot compile polymorphic function: type variable \\"t94\\" is not monomorphic
even with the following;
|> map(
fn: (r) => {
serialnumber = ""AH20230614""
suffix = strings.substring(v: serialnumber,start:1,end:3)
return {r with machine_id: suffix}
},
)
I get;
cannot compile polymorphic function @ 10:15-14:14: type variable \\"t81\\" is not monomorphic
This issue has had no recent activity and will be closed soon.