UDF stream is empty


#1

Hello guys i have registerd UDF (Nodejs client), but when i apply that UDF stream is always null

    asclient.client.udfRegister('./lua/lm.lua', function (error) {
	  if (error) {
		console.error('Error: %s [%d]', error.message, error.code)
	  }
	});

Above is my udf registration and when i aql > show modules i see its loaded. After that i try to apply this

var key = new Key(‘chat’, ‘conversations’, 1); var udf = { module: ‘lm’, funcname: ‘getlm’, args: [ctoken]}

asclient.client.apply(key, udf, function (error, result) {
  if (error) throw error
	console.log(result);
  })

But always return null Here is my lua file content

function getlm(stream, conversation)

	return stream
end

I just return the strem to check if there is some data, but is empty… Hope that info helps.


#2

You cannot return back a ‘stream’.


#3

Than how to check if my script works ? if u put this

function getlm(stream, conversation)

	local function transformer(rec)
        local touple = map()
        touple["1"] = rec["1"]
        touple["2"] = rec["2"]
        touple["3"] = rec["3"]
        return touple
    end
	
	return stream:map(transformer)
end

Map the fields and i get error like

AerospikeError: /opt/aerospike/usr/udf/lua/lm.lua:17: attempt to call method 'map' (a nil value)


#4

continue here: https://stackoverflow.com/questions/54343469/aerospike-nodejs-register-udf-with-lua-file