blob: 467be50696b6a21aa73a0c25f119305ec1f63a1f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/* 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.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<Struct<key:String,subkey:String,value:String>>>>)->Optional<Struct<sumByAllVal:Uint32>>>, $udfScript);
--INSERT INTO Output
REDUCE Input1 ON key USING ALL $udf(TableRow());
|