aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/pg/pg_iterate.sql
blob: 2c58f3957bc67eed1c7a40b7751f4b6a5d0722b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
pragma warning("disable","4510");
$init = ListCreate(Struct<n:Int32>);
$transform = ($value)->{
    return ListMap(ListFilter($value, ($r)->($r.n<5)), ($r)->(<|n:$r.n + 1|>));
};

select * from AS_TABLE(Yql::PgIterateAll($init,$transform)) order by n;

$init = [<|n:1|>];
$transform = ($value)->{
    return ListMap(ListFilter($value, ($r)->($r.n<5)), ($r)->(<|n:$r.n + 1|>));
};

select * from AS_TABLE(Yql::PgIterateAll($init,$transform)) order by n;

$init = [<|n:1|>, <|n:1|>, <|n:2|>];
$transform = ($value)->{
    return ListFlatMap($value, ($_r)->([<|n:1|>,<|n:2|>,<|n:2|>]));
};

select * from AS_TABLE(Yql::PgIterate($init,$transform)) order by n;