# Stream UDF failed with: attempt to call method 'map' (a nil value)

**URL:** <https://discuss.aerospike.com/t/stream-udf-failed-with-attempt-to-call-method-map-a-nil-value/7719>\
**Category:** User Defined Functions (UDF)\
**Tags:** udf\
**Created:** [August 5, 2020, 5:06am UTC](https://discuss.aerospike.com/t/stream-udf-failed-with-attempt-to-call-method-map-a-nil-value/7719 "2020-08-05T05:06:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![makai](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/makai/32/1488_2.png) [@makai](https://discuss.aerospike.com/u/makai)\
**Post date:** [August 5, 2020, 5:06am UTC](https://discuss.aerospike.com/t/stream-udf-failed-with-attempt-to-call-method-map-a-nil-value/7719/1 "2020-08-05T05:06:35Z")

</div>

I’m testing udf on my aerospike server. My test udf code is:

> ```
> function topn_item_stream_udf(s, topn)
> local function item_map_fn(record)
> local item = map {key=record["note_id"], value=record["index_hot_click"]/(record["index_hot_pv"]+1)}
> return item
> end
> return stream : map(item_map_fn)
> end
> 
> ```

When I run command in aql like this:

> execute topn\_item.topn\_item\_stream\_udf() on algo.note\_stat\_2

I got error:

> result “run/work/usr/udf/lua/topn\_item.lua:9: attempt to call method ‘map’ (a nil value)”

What’s the problem with my server or my code? Could someone give me some help? Thanks!
