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

# prepare python udf
(let i64 (DataType 'Int64))
(let udfType (CallableType '() '((ListType i64))))
(let udfScript (String '@@
def g0():
    def gen():
        for x in xrange(1, 4):
            yield long(x + 42)
    return gen
@@))
(let udf (ScriptUdf 'Python 'g0 udfType udfScript))

# call udf
(let result (Apply udf))

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

# finish
(return (Commit! world sink))
)