I think you are not passing the record to filter function.
local myfilter = my_email_filter(record, key, email) … Then in my_email_filter(record, key, email) use the type check before compare.
local val = record[key] if type(val) == ‘string’ then …
Also see: How to use Aggregation? - #2 by pgupta
I typically put my filter function inside the main function i am calling so i can pass my arguments to it without changing the signature of the filter function. If I recall, API says filter function can be passed only one argument - the record. So keen to know if your construct works.