aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/s-expressions/suites/Optimizers/SkipWhileOverLiterals.yql
blob: e661d70dde66968fb70da405127eda29fe174331 (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
41
42
43
44
(
(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))

(let res_sink (DataSink 'result))

(let listVal (AsList (Int32 '0)))
(let listVal (Append listVal (Int32 '1)))

(let emptyList (List (ListType (DataType 'Int32))))
(let emptyStream (EmptyIterator (StreamType (DataType 'Int32))))
(let emptyOptional (Nothing (OptionalType (DataType 'Int32))))

(let notOptLambda (lambda '(x) (< x (Int32 '1))))

# Skip while true: []
(let res (SkipWhile listVal (lambda '(x) (Bool 'true))))
(let world (Write! world res_sink (Key) res '('('type))))

# Skip while false: [0, 1]
(let res (SkipWhile listVal (lambda '(x) (Bool 'false))))
(let world (Write! world res_sink (Key) res '('('type))))

# Skip from empty list: []
(let res (SkipWhile emptyList notOptLambda))
(let world (Write! world res_sink (Key) res '('('type))))

# Skip from empty stream: []
(let res (SkipWhile emptyStream notOptLambda))
(let res (Collect res))
(let world (Write! world res_sink (Key) res '('('type))))

# Skip from empty optional: []
(let res (SkipWhile emptyOptional notOptLambda))
(let world (Write! world res_sink (Key) res '('('type))))

# General case: [1]
(let res (SkipWhile listVal notOptLambda))
(let world (Write! world res_sink (Key) res '('('type))))

(let world (Commit! world res_sink))
(return world)

)