blob: 079ff55899c6f21e13e8ecca9456252cba36760d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/* syntax version 1 */
/* postgres can not */
USE plato;
$udfScript = @@
import functools
def Len(key, input):
sumByValue = functools.reduce(lambda x,y: x + int(y.value), input, 0)
return (sumByValue % 2, {"sumByVal": sumByValue})
@@;
$udf = Python::Len(Callable<(String, Stream<Struct<key:String,subkey:String,value:String>>)->Variant<Struct<sumByVal:Uint32>,Struct<sumByVal:Uint32>>>, $udfScript);
$i, $j = (REDUCE Input ON key USING $udf(TableRow()));
select * from $i order by sumByVal;
select * from $j order by sumByVal;
|