aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/binding/compact_named_subq_actions.sql
blob: a823be2af3c961920b55d7829097bae41e0811d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
pragma CompactNamedExprs;

$src = select 1;

define subquery $sub1() as
  select * from $src;
end define;

$foo = 1+2;

define subquery $sub2($sub, $extra) as
  select a.*, $extra as extra, $foo as another from $sub() as a
end define;

select * from $sub1();
select * from $sub2($sub1, 1);
select * from $sub2($sub1, "aaa");

define action $hello_world($sub, $name, $suffix?) as
    $name = $name ?? ($suffix ?? "world");
    select "Hello, " || $name || "!" from $sub();
end define;

do empty_action();
do $hello_world($sub1, null);
do $hello_world($sub1, null, "John");
do $hello_world($sub1, null, "Earth");