blob: 36a70677e4fd9449baae355b9080955ad151e1b0 (
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
31
|
(
(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))
# 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('x', x) + ':' + func('y', x)
@@))
(let udf (ScriptUdf 'Python '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))
)
|