aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/action/eval_code.sql
blob: 10d0360aea8f0a65616e01edcc9fc0ac17168262 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* syntax version 1 */
/* postgres can not */
select EvaluateCode(FuncCode("Int32",AtomCode("1")));

$inc = EvaluateCode(LambdaCode(($x)->{return 
    FuncCode("+", $x, FuncCode("Int32", AtomCode("1")))}));
select $inc(1);

$addPrefixForMembers = ($strValue)->{
    $code = EvaluateCode(LambdaCode(($str)->{
        $members = StructTypeComponents(TypeHandle(TypeOf($strValue)));
        $list = ListMap($members, ($x)->{
            return ListCode(AtomCode("prefix" || $x.Name),FuncCode("Member", $str, AtomCode($x.Name)));
        });

        return FuncCode("AsStruct",$list);
    }));
    return $code($strValue);
};

select $addPrefixForMembers(AsStruct(1 as foo, "2" as bar));