PythonSum.yqls 526 B

12345678910111213141516171819202122
  1. (
  2. (let config (DataSource 'config))
  3. # prepare python udf
  4. (let ui32 (DataType 'Uint32))
  5. (let udfType (CallableType '() '(ui32) '(ui32) '(ui32)))
  6. (let udfScript (String '"def Sum(x, y): return x + y"))
  7. (let udf (ScriptUdf 'Python3 'Sum udfType udfScript))
  8. # call udf
  9. (let x (Uint32 '10))
  10. (let y (Uint32 '32))
  11. (let result (Apply udf x y))
  12. # output result with type
  13. (let res_sink (DataSink 'result))
  14. (let world (Write! world res_sink (Key) result '( '('type) )))
  15. # finish
  16. (let world (Commit! world res_sink))
  17. (return world)
  18. )