aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/udfs/common/yson2/test/cases/GenericConvertTo.sql
blob: b23d524cff0ba8ab2fdd8ad7998723f5dc7549ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SELECT
    Yson::ConvertTo(Yson::Parse(Yson("%true")), Bool) AS `bool`,
    Yson::ConvertTo(Yson::Parse(Yson("123")), Int64) AS `int`,
    Yson::ConvertTo(Yson::Parse(Yson("123u")), Uint8) AS `uint`,
    Yson::ConvertTo(Yson::Parse(Yson("1.23")), Double?) AS optional_double,
    Yson::ConvertTo(Yson::Parse(Yson("#")), Int32?) AS empty_int,
    Yson::ConvertTo(Yson::Parse(Yson("\"123\"")), String) AS `string`,
    Yson::ConvertTo(Yson::Parse(Yson("\"приём\"")), Utf8) AS `utf8`,
    Yson::ConvertTo(Yson::Parse(Yson("{a=b;c=#}")), Yson?) AS `yson`,
    Yson::ConvertTo(Yson::Parse(Yson("[{a=1};{a=2};{a=3}]")), Json?) AS `json`,
    Yson::ConvertTo(Yson::Parse(Yson("[1;2;3]")), List<Int64>) AS int_list,
    Yson::ConvertTo(Yson::Parse(Yson("[[1;2];[3;#]]")), List<List<Int64?>>) AS nested_list,
    Yson::ConvertTo(Yson::Parse(Yson("{foo=1;bar=2}")), Dict<String,Int64>) AS int_dict,
    Yson::ConvertTo(Yson::Parse(Yson("[%false;1;\"foo\";[1;2]]")), Tuple<Bool,Int8,String?,List<Int64>>) AS `tuple`,
    Yson::ConvertTo(Yson::Parse(Yson("{a=%false;b=1;c=foo;d=[1;2];e=[1.0;bar]}")), Struct<a:Bool,b:Int8,c:String?,d:List<Int64>,e:Tuple<Double,String>>) AS `struct`,
    Yson::Serialize(Yson::ConvertTo(Yson::Parse(Yson("foo")), Resource<'Yson2.Node'>)) AS `resource`,
    Yson::ConvertTo(Yson::Parse(Yson("[-3.1416; 42.0; 0.003]")), List<Float>) AS list_of_floats,
    Yson::ConvertTo(@@{a=[1]}@@y, Struct<a: Struct<b: Int64>>?, Yson::Options(false AS Strict)) as bad_member,
    Yson::ConvertTo(@@[1;2]@@y, Tuple<Int64, Tuple<Int64>>?, Yson::Options(false AS Strict)) as bad_element;