aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverStream.yql
blob: 1ac4fd613eb2816e4024577c970917bfb947e29a (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
(

(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))
(let res_sink (DataSink 'result))

# Stream<Int32> -> Stream<Uint16> (full)
(let targetType (StreamType (DataType 'Uint16)))
(let src (Iterator (AsList (Int32 '1) (Int32 '2) (Int32 '3))))
(let cast (SafeCast src targetType))
(let world (Write! world res_sink (Key) (Collect cast) '('('type))))

# Stream<Int32> -> Stream<Uint16> (less)
(let targetType (StreamType (DataType 'Uint16)))
(let src (Iterator (AsList (Int32 '1) (Int32 '-2) (Int32 '3))))
(let cast (SafeCast src targetType))
(let world (Write! world res_sink (Key) (Collect cast) '('('type))))

# Stream<Int32?> -> Stream<Uint16> (less)
(let targetType (StreamType (DataType 'Uint16)))
(let src (Iterator (AsList (Just (Int32 '1)) (Null) (Just (Int32 '3)))))
(let cast (SafeCast src targetType))
(let world (Write! world res_sink (Key) (Collect cast) '('('type))))

(let world (Commit! world res_sink))

(return world)

)