aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/produce/reduce_with_trivial_remaps.sql
blob: 65e70e8715ec78478287b5fa20181b080a45ae77 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use plato;
pragma warning("disable", "4510");

$udf = ($_key, $stream) -> {
   $init = ($item) -> (AsStruct(1u as cnt, $item as row));
   $switch = ($_item, $_state) -> (false);
   $update = ($item, $state) -> (AsStruct($state.cnt + 1u as cnt,
      if(($item.value > $state.row.value) ?? false, $item, $state.row) as row));
   $state = YQL::Collect(YQL::Condense1($stream, $init, $switch, $update));
   return $state;
};

REDUCE CONCAT(Input1,Input2)
presort subkey
ON key USING $udf(TableRow());