aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverStruct.yql
blob: 6654166a2701e137a6b928f13f3fb7f617bc8039 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(

(library "alterto.yql")
(import alterto_module '"alterto.yql")

(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))

(let targetType (StructType '('"a" (DataType 'Uint8)) '('"b" (DataType 'Utf8))))
(let failValue (AsStruct '('a (Uint8 '0)) '('b (Utf8 '"not converted"))))

# Struct<Int32, String> -> Struct<Uint8, Utf8>
(let value (AsStruct '('a (Int32 '1)) '('b (String 'one))))
(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue))

# Struct<Int32, String> -> Struct<Uint8, Utf8> (fail)
(let value (AsStruct '('a (Int32 '"-1")) '('b (String 'one))))
(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue))

(return world)

)