aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/aggr_factory/bottom.sql
blob: f663c39d6355e551933363997b32f079b61b00d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* syntax version 1 */
/* postgres can not */
$t = AsList(
    AsStruct(7 as a),
    AsStruct(4 as a),
    AsStruct(5 as a),
    AsStruct(1 as a),
    AsStruct(2 as a),
    AsStruct(9 as a),
    AsStruct(1 as a),
    AsStruct(9 as a)
);

$f = AGGREGATION_FACTORY("bottom", 3);

select Yql::Aggregate($t, AsTuple(), AsTuple(AsTuple(AsAtom("res"),
    $f(ListItemType(TypeOf($t)), ($z)->{ return $z.a }))));

use plato;
insert into @a select * from as_table($t);
commit;

select AGGREGATE_BY(a, $f) from @a;
select AGGREGATE_BY(distinct a, $f) from @a;