Is it possible to pass record to custom function? I’d like to call custom function from filter() that would work similarly to contains(), but it would need the whole row because it would use some if-else if-else condition block and use different columns (tags) accordingly.
Given custom function like
match = (r) => contains(value:r.g3, set: ["abc"])
I can verify that it somehow works
> row = { g3: "abc" }
> match(r:row)
true
With dataset like
#group,false,false,true,true,false,false,true,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string,string
#default,_result,,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,g1,g2,g3
,,0,2018-12-17T07:45:00.491825337Z,2019-12-17T13:45:00.491825337Z,2019-12-17T13:32:12.906454593Z,1,x,m,a,ab,abc
I get empty table as result when I include the function in filter():
data |> range(start: -1y) |> filter(fn: (r) => r._measurement == "m" and match(r))
When I inline the function body it works as expected:
> data |> range(start: -1y) |> filter(fn: (r) => r._measurement == "m" and contains(value: r.g3, set: ["abc"]))
Result: _result
Table: keys: [_start, _stop, _field, _measurement, g1, g2, g3]
_start:time _stop:time _field:string _measurement:string g1:string g2:string g3:string _value:float _time:time
------------------------------ ------------------------------ ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------------- ------------------------------
2018-12-17T09:20:10.127752113Z 2019-12-17T13:45:00.491825337Z x m a ab abc 1 2019-12-17T13:32:12.906454593Z