diff options
author | avevad <avevad@yandex-team.com> | 2024-12-09 11:48:43 +0300 |
---|---|---|
committer | avevad <avevad@yandex-team.com> | 2024-12-09 12:07:33 +0300 |
commit | 365b065ca32ba05d72f86723169f846d0ee12189 (patch) | |
tree | 5e038eb3e468aa71927441b964e326a0cbbb2e1c /yql/essentials/tests/sql/suites/expr/variant_builtins_opt.sql | |
parent | bc7efd59c3940f609c01a8af3ea6c6d69cbc456c (diff) | |
download | ydb-365b065ca32ba05d72f86723169f846d0ee12189.tar.gz |
YQL-19123 More SQL features for Variant type
More SQL features for Variant type
commit_hash:51c15343e2d24190ec59085888dfa3fd008cafcc
Diffstat (limited to 'yql/essentials/tests/sql/suites/expr/variant_builtins_opt.sql')
-rw-r--r-- | yql/essentials/tests/sql/suites/expr/variant_builtins_opt.sql | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/expr/variant_builtins_opt.sql b/yql/essentials/tests/sql/suites/expr/variant_builtins_opt.sql new file mode 100644 index 0000000000..443802fe56 --- /dev/null +++ b/yql/essentials/tests/sql/suites/expr/variant_builtins_opt.sql @@ -0,0 +1,26 @@ +$vartype = Variant<a: Optional<String>, b: Optional<String>>; + +$handle_a = ($x) -> { return CAST(($x || "1") AS Uint32); }; +$handle_b = ($x) -> { return CAST(($x || "2") AS Uint32); }; + +$var_a = Variant("5", "a", $vartype); +$var_b = Variant("6", "b", $vartype); + +SELECT + Visit(Just($var_a), $handle_a AS a, $handle_b AS b), + Visit(Just($var_b), $handle_a AS a, $handle_b AS b), + VisitOrDefault(Just($var_b), Just(777u), $handle_a AS a), + VariantItem(Just($var_b)) +; + +$vartype_t = Variant<Optional<String>, Optional<String>>; + +$var_1 = Variant("7", "0", $vartype_t); +$var_2 = Variant("8", "1", $vartype_t); + +SELECT + Visit(Just($var_1), $handle_a, $handle_b), + Visit(Just($var_2), $handle_a, $handle_b), + VisitOrDefault(Just($var_2), $handle_a, Just(777u)), + VariantItem(Just($var_b)) +; |