Lua Stream UDF attempt to call method 'filter' (a nil value)

Hi there

I’m trying to use Stream UDFs to filter results to match sets, and i’m just starting out with an incredibly basic matching UDF, however i’m finding that the UDF doesn’t seem to work properly, complaining that the filter method doesn’t exist.

here’s the UDF i’m trying to use:

local function limitation_filter(zone)
return function(record)
    if record['dev_long'] == "Ubuntu" then
        return true
    else
        return false
    end
end
end

function stream_rows_udf(stream, zone)
    local limfilter = limitation_filter(limitations)
    return stream : filter(limfilter)
end

and i’m calling it with

aql> execute devfilter.stream_rows_udf(‘Macintosh’) on forecast.betapig4 where PK = 890

and i get this response:

Error: (100) /opt/aerospike/usr/udf/lua/devfilter.lua:13: attempt to call method ‘filter’ (a nil value)

any help would be greatly appreciated.

Hi,

Please take a look at this example: [Query with multiple filters][1].

I hope this helps. [1]: https://github.com/aerospike/query-with-filters

so i should be using the aggregate command rather than execute? that’s the only difference i can see. however when i run aggregate i get :

ERROR Lua Create Error: module ‘aerospike’ not found

The LUA_SYSPATH is set to /opt/aerospike/sys/udf/lua and that contains all the system lua files, aerospike.lua as.lua etc

i can’t see that i’m doing much different to what that example recommends.

okay so it looks like the problem i was having is not having the lua dependencies on the client machine, i assumed that all of the UDF was being run serverside.

@Alexrussellsaw,

Did this realization solve your issue, or do you have further questions?