aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/expr/pg_try_member.sql
blob: 66eb44a8f5dcd8f044e9ccb4809fde5747f8e9f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* postgres can not */
/* syntax version 1 */
/* yt can not */

$s = <|a:1p|>;
$js = Just($s);
$es = Nothing(Struct<a:PgInt>?);

-- fully equivalent to <struct>.<name>
select
  TryMember($s, "a", null),
  TryMember($js, "a", null),
  TryMember($es, "a", null),
;

-- TypeOf TryMember is type of third argument
-- field type should either match third type exactly, or (if the third type is optional) 
-- Optional(field) should be equal to third type
select
  TryMember($s, "a", 999p),
  TryMember($s, "a", Just(999p)),

  TryMember($js, "a", 999p),
  TryMember($js, "a", Just(999p)),

  TryMember($es, "a", 999p),
  TryMember($es, "a", Just(999p)),
;