aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/lambda/list_aggregate.sql
blob: a4c1093ae732d57b33880754b6024ce6c5a96da1 (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 ListMap(
        $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;