aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/flatten_by/flatten_mode.sql
blob: 655c4940e1429aa5ed0c929690e71c37c2934e38 (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
31
32
33
34
35
36
37
38
39
40
/* postgres can not */
USE plato;

SELECT
    *
FROM (SELECT Just(1) AS x)
FLATTEN OPTIONAL BY x;

$lst = AsList(1,2,3);
SELECT
    *
FROM (SELECT $lst AS x)
FLATTEN LIST BY x ORDER BY x;

SELECT
    x
FROM (SELECT Just($lst) AS x)
FLATTEN LIST BY x ORDER BY x;

SELECT
    *
FROM (SELECT Just($lst) AS x)
FLATTEN OPTIONAL BY x ORDER BY x;

$dct = AsDict(AsTuple(1,"foo"),AsTuple(2,"bar"),AsTuple(3,"baz"));

SELECT
    *
FROM (SELECT $dct AS x)
FLATTEN DICT BY x ORDER BY x;

SELECT
    x
FROM (SELECT Just($dct) AS x)
FLATTEN DICT BY x ORDER BY x;

SELECT
    ListSort(DictItems(x))
FROM (SELECT Just($dct) AS x)
FLATTEN OPTIONAL BY x;