blob: afa021dd112ea6eb648374bf3ac9eca8fe1fcf6e (
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))
# Struct<Int32, String, Utf8?> -> Struct<Uint8?, Utf8?> (good)
(let targetType (StructType '('a (OptionalType (DataType 'Uint8))) '('b (OptionalType (DataType 'Utf8)))))
(let value (AsStruct '('a (Int32 '1)) '('b (String 'one)) '('c (Nothing (OptionalType (DataType 'Utf8))))))
(let cast (StrictCast value targetType))
(let world (Write! world res_sink (Key) cast '('('type))))
# Struct<Int32, String, String?> -> Struct<Int8, Utf8, Float?>? (fail)
(let targetType (StructType '('a (DataType 'Int8)) '('b (DataType 'Utf8)) '('c (OptionalType (DataType 'Float)))))
(let value (AsStruct '('a (Int32 '-1)) '('b (String 'one)) '('d (Just (String 'one)))))
(let cast (StrictCast value targetType))
(let world (Write! world res_sink (Key) cast '('('type))))
(let world (Commit! world res_sink))
(return world)
)
|