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

$udfScript = @@
import functools
def Len(stream):
    sums = [functools.reduce(lambda x,y: x + int(y[1].value), pair[1], 0) for pair in stream]
    return {"sumByAllVal":functools.reduce(lambda x,y: x + y, sums, 0)}
@@;

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

REDUCE Input1, Input1 ON key USING ALL $udf(TableRow());