PythonPartialCall.yqls 546 B

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