aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/s-expressions/suites/Udf/PythonSum.yql
blob: ef5f4e154935796916be5049272ebc34b53249b7 (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
(
(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))

# prepare python udf
(let ui32 (DataType 'Uint32))
(let udfType (CallableType '() '(ui32) '(ui32) '(ui32)))
(let udfScript (String '"def Sum(x, y): return x + y"))
(let udf (ScriptUdf 'Python3 'Sum udfType udfScript))

# call udf
(let x (Uint32 '10))
(let y (Uint32 '32))
(let result (Apply udf x y))

# output result with type
(let res_sink (DataSink 'result))
(let world (Write! world res_sink (Key) result '( '('type) )))

# finish
(let world (Commit! world res_sink))
(return world)
)