reduce.sql 437 B

1234567891011
  1. /* postgres can not */
  2. /* custom check: len(yt_res_yson[0][b'Write'][0][b'Data']) < 8 */
  3. USE plato;
  4. $udf = YQL::@@(lambda '(key stream) (AsStruct
  5. '('key key) '('summ (Collect (Condense stream (Uint32 '0) (lambda '(item state) (Bool 'False)) (lambda '(item state) (Add state item)))))
  6. ))@@;
  7. $res = (REDUCE Input TABLESAMPLE BERNOULLI(30) REPEATABLE(1) ON key USING $udf(cast(value as uint32) ?? 0));
  8. select * from $res order by key;