aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/lambda/list_aggregate_flatmap.sql
blob: 8d88b0b78cc72030a6b014e3c74a4d415b1833a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* syntax version 1 */
$subst = ($names, $indices) -> {
    RETURN ListFlatMap(
        $indices,
        ($index) -> {
            RETURN $names[$index];
        }
    );
};

$table = (
    SELECT AsList("a", "b") AS names, AsList(0, 0, 1) AS indices
    UNION ALL
    SELECT AsList("c", "d") AS names, AsList(0, 1, 1) AS indices
);

SELECT AGGREGATE_LIST($subst(names, indices))
FROM $table;