Search code examples
aerospike

Passing parameters for record udf with ascli - bug?


According to the documentation, ascli should be able to take arguments when applying a record udf against a record (docs on ascli command 'udf-record-apply').

However, I have failed to get this to work. Here is a minimal example:

-- Minimal failing example
function testfunc(rec, param1, param2, param3)
  local ret = map()

  -- Just print what was passed into UDF
  ret['debug_param1'] = param1
  ret['debug_param2'] = param2
  ret['debug_param3'] = param3
  return ret
end

It was registered with ascli udf-put minimal-example.lua. When used with aql, the record udf works fine:

aql> execute minimal-example.testfunc(12345) on test.test where PK = '1'
+----------------------------------------------------------------+
| testfunc                                                       |
+----------------------------------------------------------------+
| {"debug_param1":12345, "debug_param2":NIL, "debug_param3":NIL} |
+----------------------------------------------------------------+
1 row in set (0.000 secs)

However, when used from cli with param1 = 12345, it ignores any parameters passed to the udf:

$ ascli udf-record-apply test test 1 minimal-example testfunc 12345
{ "debug_param1": null, "debug_param2": null, "debug_param3": null }

Are my calls to ascli incorrect or is this a bug?


Solution

  • You can pass in integer lists (or empty lists) into UDFs via ascli. For example:

    ascli udf-record-apply test test 1 udfModule funcName [123] [234,235] [1,[2]] []

    A couple of notes:
    - Parameter passing appears to work only for integer lists (no strings, maps, etc.)
    - There's no white space after the comma in the list