blob: 55f7637e3204908e655219520b78e07f03ab9f45 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
(
(let config (DataSource 'config))
# common types
(let ui64 (DataType 'Uint64))
(let str (DataType 'String))
# callable func
(let funcType (CallableType '() '(str) '(str) '(ui64)))
(let func (Udf 'SimpleUdf.Repeat))
# python udf
(let udfType (CallableType '() '(str) '(funcType) '(ui64)))
(let udfScript (String '@@
def new_string(func, x):
return func(b'x', x) + b':' + func(b'y', x)
@@))
(let udf (ScriptUdf 'Python3 'new_string udfType udfScript))
# call udf
(let x (Uint64 '3))
(let result (Apply udf func x))
# output result with type
(let res_sink (DataSink 'result))
(let world (Write! world res_sink (Key) result '( '('type) )))
# finish
(return (Commit! world res_sink))
)
|