{"action":"closed","issue":{"url":"https://api.github.com/repos/aerospike/aerospike-client-go/issues/63","labels_url":"https://api.github.com/repos/aerospike/aerospike-client-go/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/aerospike/aerospike-client-go/issues/63/comments","events_url":"https://api.github.com/repos/aerospike/aerospike-client-go/issues/63/events","html_url":"https://github.com/aerospike/aerospike-client-go/issues/63","id":79630608,"number":63,"title":"Maps aren't being treated as maps in UDF ","user":{"login":"Abramovic","id":981933,"avatar_url":"https://avatars.githubusercontent.com/u/981933?v=3","gravatar_id":"","url":"https://api.github.com/users/Abramovic","html_url":"https://github.com/Abramovic","followers_url":"https://api.github.com/users/Abramovic/followers","following_url":"https://api.github.com/users/Abramovic/following{/other_user}","gists_url":"https://api.github.com/users/Abramovic/gists{/gist_id}","starred_url":"https://api.github.com/users/Abramovic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Abramovic/subscriptions","organizations_url":"https://api.github.com/users/Abramovic/orgs","repos_url":"https://api.github.com/users/Abramovic/repos","events_url":"https://api.github.com/users/Abramovic/events{/privacy}","received_events_url":"https://api.github.com/users/Abramovic/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-22T22:11:25Z","updated_at":"2015-06-01T08:14:25Z","closed_at":"2015-06-01T08:14:25Z","body":"Whenever I store maps/json using the Go client and try to access that bin using UDF I keep getting the type as \"userdata\" instead of a table or a list. \r\n\r\nMessage: bad argument #1 to 'format' (string expected, got userdata)\r\n\r\n```\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\tas \"github.com/aerospike/aerospike-client-go\"\r\n\t\"log\"\r\n\t\"strconv\"\r\n\t\"time\"\r\n)\r\n\r\nconst udfFilter = `\r\nfunction queryTest(s, rec)\r\n  local time = os.time()\r\n  local function map_value_merger(mapval1, mapval2)\r\n    return mapval1 + mapval2\r\n  end\r\n  local function reduce_results(a,b)\r\n    return map.merge(a,b,map_value_merger)\r\n  end\r\n\r\n  function apply_totalmap_cxt(mymap, rec)\r\n\t\tlocal topics = rec[\"Data\"]\r\n\t\tif topics ~= nil then\r\n\t\t\tfor k in list.iterator(topics) do\r\n\t\t\t\twarn(k)\r\n\t\t\t\tif mymap[k] == nil then\r\n\t\t\t\t\tmymap = 0\r\n\t\t\t\tend\r\n\t\t\t\tmymap[k] = mymap[k] + 1\r\n      end\r\n\t\tend\r\n    return mymap\r\n  end\r\n\treturn s : aggregate(map(), apply_totalmap_cxt) : reduce(reduce_results)\r\nend\r\n\r\n`\r\n\r\n\r\nfunc main() {\r\n\r\n\tclient, err := as.NewClient(\"127.0.0.1\", 3000)\r\n\tif err != nil {\r\n\t\tlog.Fatal(err)\r\n\t}\r\n\r\n\tkey, _ := as.NewKey(\"test\", \"pets\", \"example_key\")\r\n\r\n\ttopics := []map[interface{}]interface{}{}\r\n\ttopic1 := map[interface{}]interface{}{}\r\n\ttopic1[\"animal\"] = \"Dogs\"\r\n\ttopic2 := map[interface{}]interface{}{}\r\n\ttopic2[\"animal\"] = \"Cats\"\r\n\r\n\ttopics = append(topics, topic1)\r\n\ttopics = append(topics, topic2)\r\n\r\n\tdata := as.BinMap{\r\n    \"CreatedAt\": time.Now().Unix(),\r\n    \"bin2\": \"An elephant is a mouse with an operating system\",\r\n\t\t\"Data\": topics,\r\n  }\r\n\r\n\tclient.Put(nil, key, data)\r\n\r\n\tregTask, err := client.RegisterUDF(nil, []byte(udfFilter), \"queryTest.lua\", as.LUA)\r\n\tif err != nil {\r\n\t\tlog.Fatal(err)\r\n\t}\r\n\tfor {\r\n\t\tif err := <-regTask.OnComplete(); err == nil {\r\n\t\t\tbreak\r\n\t\t} else {\r\n\t\t\tlog.Println(err)\r\n\t\t}\r\n\t}\r\n\r\n\tstm := as.NewStatement(\"test\", \"pets\")\r\n\tstm.SetAggregateFunction(\"queryTest\", \"queryTest\", nil, true)\r\n\r\n\trecordset, err := client.Query(nil, stm)\r\n\tif err != nil {\r\n\t\tlog.Fatal(err)\r\n\t}\r\n\r\n\tresults := map[string]int{}\r\n\r\nL:\r\n\tfor {\r\n\t\tselect {\r\n\t\tcase rec, _ := <-recordset.Records:\r\n\t\t\tif rec == nil {\r\n\t\t\t\tbreak L\r\n\t\t\t}\r\n\t\t\tif result, ok := rec.Bins[\"SUCCESS\"].(map[interface{}]interface{}); ok {\r\n\t\t\t\tfor k, v := range result {\r\n\t\t\t\t\tkey := \"\"\r\n\t\t\t\t\tif r, ok := k.(int); ok {\r\n\t\t\t\t\t\tkey = fmt.Sprintf(\"%d\", r)\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif r, ok := k.(string); ok {\r\n\t\t\t\t\t\tkey = r\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif r, ok := v.(int); ok {\r\n\t\t\t\t\t\tresults[key] = results[key] + r\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfor k, v := range results {\r\n\t\tfmt.Println(k + \" :: \" + strconv.Itoa(v))\r\n\t}\r\n}\r\n```"}}