as_dict_dict_key.sql 661 B

123456789101112131415161718192021222324
  1. /* postgres can not */
  2. $d1 = AsDict(
  3. AsTuple(AsList(1,2,3),"foo"),
  4. AsTuple(AsList(1,2),"bar")
  5. );
  6. $d2 = AsDict(
  7. AsTuple(AsList(1,3),"baz"),
  8. AsTuple(AsList(1,2),"qwe")
  9. );
  10. $d3 = DictCreate(DictKeyType(TypeOf($d2)), DictPayloadType(TypeOf($d2)));
  11. $d = AsDict(
  12. AsTuple($d1, 17),
  13. AsTuple($d2, 32)
  14. );
  15. select ListSort(ListFlatten(ListMap(DictItems($d), ($x) -> {return ListMap(DictItems($x.0), ($y) -> {return ($y, $x.1)})}))),
  16. ListSort(ListFlatten(ListMap(DictKeys($d), ($x) -> {return DictItems($x)}))),
  17. ListSort(DictPayloads($d));
  18. select DictLookup($d,$d1), DictLookup($d,$d3);
  19. select DictContains($d,$d1), DictContains($d,$d3);