aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/produce/reduce_with_python.sql
blob: 6bdf0efb2447b76c9989c426093c3bf0eea401a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* postgres can not */
/* syntax version 1 */
USE plato;

$udfScript = @@
import functools
def Len(key, input):
    return {"value":functools.reduce(lambda x,y: x + 1, input, 0)}
@@;

$udf = Python::Len(Callable<(String, Stream<String>)->Struct<value:Uint32>>, $udfScript);

--INSERT INTO Output
$res = (REDUCE Input1 ON key USING $udf(value));

select * from $res order by value;