variant_builtins_opt.sql 809 B

1234567891011121314151617181920212223242526
  1. $vartype = Variant<a: Optional<String>, b: Optional<String>>;
  2. $handle_a = ($x) -> { return CAST(($x || "1") AS Uint32); };
  3. $handle_b = ($x) -> { return CAST(($x || "2") AS Uint32); };
  4. $var_a = Variant("5", "a", $vartype);
  5. $var_b = Variant("6", "b", $vartype);
  6. SELECT
  7. Visit(Just($var_a), $handle_a AS a, $handle_b AS b),
  8. Visit(Just($var_b), $handle_a AS a, $handle_b AS b),
  9. VisitOrDefault(Just($var_b), Just(777u), $handle_a AS a),
  10. VariantItem(Just($var_b))
  11. ;
  12. $vartype_t = Variant<Optional<String>, Optional<String>>;
  13. $var_1 = Variant("7", "0", $vartype_t);
  14. $var_2 = Variant("8", "1", $vartype_t);
  15. SELECT
  16. Visit(Just($var_1), $handle_a, $handle_b),
  17. Visit(Just($var_2), $handle_a, $handle_b),
  18. VisitOrDefault(Just($var_2), Just(777u), $handle_a),
  19. VariantItem(Just($var_b))
  20. ;