aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapsWithDependsOn.yqls
blob: 0553caa8fd80715acc58abb42704a3c161d74650 (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
(
#comment
(let mr_source (DataSource 'yt 'plato))
(let res_sink (DataSink 'result))

(let list (AsList (String 'a) (String 'b) (String 'c)))

(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '()))
(let world (Left! x))
(let table (Right! x))

(let inner1 (FlatMap table (lambda '(row) (OptionalIf (> (Member row 'key) (String '100)) (AsStruct '('key1 (Member row 'key)))))))

(let inner2 (FlatMap table (lambda '(row) (Just (AsStruct '('key1 (Member row 'key)))))))

(let outer (lambda '(input) (FlatMap input (lambda '(row)
    (Just
        (AsStruct
            '('key (Member row 'key1))
            '('value (ToOptional (Collect (Condense
                (Iterator list (DependsOn row))
                (String '"")
                (lambda '(item state) (Bool 'False))
                (lambda '(item state) (Concat state item))
            ))))
        )
    )
))))


(let world (Write! world res_sink (Key) (Apply outer inner1) '('('type))))
(let world (Write! world res_sink (Key) (Apply outer inner2) '('('type))))
(let world (Commit! world res_sink))
(return world)
)