aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/produce/yql-10297.sql
blob: 9622221e1520dbef2419975f1b9a3b7d5da3c06e (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
28
29
30
/* syntax version 1 */
/* postgres can not */
DEFINE SUBQUERY $t() AS
  select * from as_table([<|key:"0"|>, <|key:"1"|>]);
END DEFINE;

DEFINE SUBQUERY $split_formula_log($in) AS
    $parition = ($row) -> {
        $recordType = TypeOf($row);
        $varType = VariantType(TupleType($recordType, 
                                        $recordType));
        RETURN case
                when $row.key = "0" then
                Variant($row, "0", $varType)
                
                when $row.key = "1" then
                Variant($row, "1", $varType)
                else null
            end
        ;
    };
    
    PROCESS $in() USING $parition(TableRow());
END DEFINE;


$a, $b = (PROCESS $split_formula_log($t));
select * from $a;
select * from $b;