# UDF stream is empty

**URL:** <https://discuss.aerospike.com/t/udf-stream-is-empty/5874>\
**Category:** General Discussion\
**Created:** [January 24, 2019, 2:12pm UTC](https://discuss.aerospike.com/t/udf-stream-is-empty/5874 "2019-01-24T14:12:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Idlle](https://avatars.discourse-cdn.com/v4/letter/i/3d9bf3/32.png) [@Idlle](https://discuss.aerospike.com/u/Idlle)\
**Post date:** [January 24, 2019, 2:12pm UTC](https://discuss.aerospike.com/t/udf-stream-is-empty/5874/1 "2019-01-24T14:12:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pgupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pgupta/32/2351_2.png) [@pgupta](https://discuss.aerospike.com/u/pgupta)\
**Post date:** [January 24, 2019, 4:16pm UTC](https://discuss.aerospike.com/t/udf-stream-is-empty/5874/2 "2019-01-24T16:16:39Z")

</div>

You cannot return back a ‘stream’.

---

<div class="post-metadata">

**Author:** ![Idlle](https://avatars.discourse-cdn.com/v4/letter/i/3d9bf3/32.png) [@Idlle](https://discuss.aerospike.com/u/Idlle)\
**Post date:** [January 24, 2019, 4:25pm UTC](https://discuss.aerospike.com/t/udf-stream-is-empty/5874/3 "2019-01-24T16:25:00Z")

</div>

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)`

---

<div class="post-metadata">

**Author:** ![pgupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pgupta/32/2351_2.png) [@pgupta](https://discuss.aerospike.com/u/pgupta)\
**Post date:** [January 24, 2019, 4:42pm UTC](https://discuss.aerospike.com/t/udf-stream-is-empty/5874/4 "2019-01-24T16:42:33Z")

</div>

continue here: [node.js - Aerospike Nodejs register UDF with .lua file - Stack Overflow](https://stackoverflow.com/questions/54343469/aerospike-nodejs-register-udf-with-lua-file)
