reduce_all_multi_in.sql 562 B

123456789101112131415
  1. /* syntax version 1 */
  2. /* postgres can not */
  3. /* dqfile can not */
  4. USE plato;
  5. $udfScript = @@
  6. import functools
  7. def Len(stream):
  8. sums = [functools.reduce(lambda x,y: x + int(y[1].value), pair[1], 0) for pair in stream]
  9. return {"sumByAllVal":functools.reduce(lambda x,y: x + y, sums, 0)}
  10. @@;
  11. $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);
  12. REDUCE Input1, Input1 ON key USING ALL $udf(TableRow());