aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/aggr_factory/histogram.sql
blob: 1a058a8f2a03b69d53d65a50048d8004b65f227f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* syntax version 1 */
/* postgres can not */
$t = AsList(AsStruct(1 as a),AsStruct(2 as a));
$f = AGGREGATION_FACTORY("histogram");

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

$f = AGGREGATION_FACTORY("histogram", 5);

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

use plato;
insert into @a select AsTuple(a, 1.0) as aa from as_table($t);
commit;
select AGGREGATE_BY(aa,$f) from @a;