reduce_multi_out.sql 540 B

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