aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/expr/static_fold.sql
blob: 9118da0e06fa88adc095834465bccccf395900bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* syntax version 1 */

$st_many = <|a: "one", b: "two", c: "three", d: "four"|>;
$st_single = <|a: "zero"|>;
$st_empty = <||>;
$tup = AsTuple("first", "second");

$concat = ($item, $state) -> { return $state || $item; };
$start = ($value) -> { return "(" || $value || ")"; };

SELECT
    StaticFold($st_many, "->", $concat),
    StaticFold($st_single, "->", $concat),
    CAST(StaticFold($st_empty, "->", $concat) AS Optional<String>),
    StaticFold($tup, "->", $concat);

SELECT
    StaticFold1($st_many, $start, $concat),
    StaticFold1($st_single, $start, $concat),
    CAST(StaticFold1($st_empty, $start, $concat) AS Optional<String>),
    StaticFold1($tup, $start, $concat);