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

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

# Dict<Int32, String> -> Dict<Uint8, Utf8> (good)
(let targetType (DictType (DataType 'Uint8) (DataType 'Utf8)))
(let src (AsDict '((Int32 '1) (String 'one)) '((Int32 '2) (String 'two)) '((Int32 '3) (String 'three))))
(let cast (StrictCast src targetType))
(let world (Write! world res_sink (Key) cast '('('type))))

# Dict<Int32, String> -> Dict<Int64, Utf8> (fail)
(let targetType (DictType (DataType 'Int64) (DataType 'Utf8)))
(let src (AsDict '((Int32 '1) (String 'one)) '((Int32 '2) (String '"\xff\xfe")) '((Int32 '3) (String 'three))))
(let cast (StrictCast src targetType))
(let world (Write! world res_sink (Key) cast '('('type))))

(let world (Commit! world res_sink))

(return world)

)