coalesce_complex.sql 970 B

12345678910111213141516171819202122232425262728293031323334353637
  1. USE plato;
  2. $strings = [
  3. <|key:Just(Just("foo")), subkey:Just("bar"), value:1|>,
  4. <|key:Just(Nothing(String?)), subkey:Just("two"), value:2|>,
  5. <|key:Nothing(String??), subkey:Just("three"), value:3|>,
  6. <|key:Nothing(String??), subkey:Nothing(String?), value:4|>,
  7. ];
  8. $tuples = [
  9. <|key:Just(Just(AsTuple(1, 2))), subkey:Just(AsTuple(3, 4)), value:1|>,
  10. <|key:Just(Nothing(Tuple<Int, Int>?)), subkey:Just(AsTuple(4, 5)), value:2|>,
  11. <|key:Nothing(Tuple<Int, Int>??), subkey:Just(AsTuple(5, 6)), value:3|>,
  12. <|key:Nothing(Tuple<Int, Int>??), subkey:Nothing(Tuple<Int, Int>?), value:4|>,
  13. ];
  14. insert into @strings
  15. select * from as_table($strings);
  16. insert into @tuples
  17. select * from as_table($tuples);
  18. commit;
  19. select
  20. value,
  21. key ?? subkey,
  22. subkey ?? "xxx",
  23. from @strings
  24. order by value;
  25. select
  26. value,
  27. key ?? subkey,
  28. subkey ?? AsTuple(100, 500),
  29. from @tuples
  30. order by value;