reduce_with_python.sql 381 B

12345678910111213141516
  1. /* postgres can not */
  2. /* syntax version 1 */
  3. USE plato;
  4. $udfScript = @@
  5. import functools
  6. def Len(key, input):
  7. return {"value":functools.reduce(lambda x,y: x + 1, input, 0)}
  8. @@;
  9. $udf = Python::Len(Callable<(String, Stream<String>)->Struct<value:Uint32>>, $udfScript);
  10. --INSERT INTO Output
  11. $res = (REDUCE Input1 ON key USING $udf(value));
  12. select * from $res order by value;