aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/s-expressions/suites/Udf/PythonPartialCall.yql
blob: 1a7f7f9dbd26d1db22f51814e744524174ce7fb6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(
(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))

# prepare python udf
(let ui32 (DataType 'Uint32))
(let udfType (CallableType '('1) '(ui32) '(ui32) '((OptionalType ui32))))
(let udfScript (String '"def Add(x, y): return x + (y if y is not None else 1)"))
(let udf (ScriptUdf 'Python3 'Add udfType udfScript))

# call udf
(let x (Uint32 '20))
(let result (Apply udf x))

# 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)
)