build-scalar,semtree-expr
1
----
const (1) (type: int)
1

build-scalar,semtree-expr
1 + 2
----
plus (type: int)
 ├── const (1) (type: int)
 └── const (2) (type: int)
1 + 2

build-scalar,semtree-expr vars=(string)
@1
----
variable (@1) (type: string)
@1

build-scalar,semtree-expr vars=(int)
@1 + 2
----
plus (type: int)
 ├── variable (@1) (type: int)
 └── const (2) (type: int)
@1 + 2

build-scalar,semtree-expr vars=(int, int)
@1 >= 5 AND @1 <= 10 AND @2 < 4
----
and (type: bool)
 ├── and (type: bool)
 │    ├── ge (type: bool)
 │    │    ├── variable (@1) (type: int)
 │    │    └── const (5) (type: int)
 │    └── le (type: bool)
 │         ├── variable (@1) (type: int)
 │         └── const (10) (type: int)
 └── lt (type: bool)
      ├── variable (@2) (type: int)
      └── const (4) (type: int)
((@1 >= 5) AND (@1 <= 10)) AND (@2 < 4)

build-scalar,semtree-expr vars=(int, int)
(@1, @2) = (1, 2)
----
eq (type: bool)
 ├── tuple (type: tuple{int, int})
 │    ├── variable (@1) (type: int)
 │    └── variable (@2) (type: int)
 └── tuple (type: tuple{int, int})
      ├── const (1) (type: int)
      └── const (2) (type: int)
(@1, @2) = (1, 2)

build-scalar,semtree-expr vars=(int)
@1 IN (1, 2)
----
in (type: bool)
 ├── variable (@1) (type: int)
 └── tuple (type: tuple{int, int})
      ├── const (1) (type: int)
      └── const (2) (type: int)
@1 IN (1, 2)

build-scalar,semtree-expr vars=(int, int)
(@1, @2) IN ((1, 2), (3, 4))
----
in (type: bool)
 ├── tuple (type: tuple{int, int})
 │    ├── variable (@1) (type: int)
 │    └── variable (@2) (type: int)
 └── tuple (type: tuple{tuple{int, int}, tuple{int, int}})
      ├── tuple (type: tuple{int, int})
      │    ├── const (1) (type: int)
      │    └── const (2) (type: int)
      └── tuple (type: tuple{int, int})
           ├── const (3) (type: int)
           └── const (4) (type: int)
(@1, @2) IN ((1, 2), (3, 4))

build-scalar,semtree-expr vars=(int, int, int, int)
(@1, @2 + @3, 5 + @4 * 2) = (@2 + @3, 8, @1 - @4)
----
eq (type: bool)
 ├── tuple (type: tuple{int, int, int})
 │    ├── variable (@1) (type: int)
 │    ├── plus (type: int)
 │    │    ├── variable (@2) (type: int)
 │    │    └── variable (@3) (type: int)
 │    └── plus (type: int)
 │         ├── const (5) (type: int)
 │         └── mult (type: int)
 │              ├── variable (@4) (type: int)
 │              └── const (2) (type: int)
 └── tuple (type: tuple{int, int, int})
      ├── plus (type: int)
      │    ├── variable (@2) (type: int)
      │    └── variable (@3) (type: int)
      ├── const (8) (type: int)
      └── minus (type: int)
           ├── variable (@1) (type: int)
           └── variable (@4) (type: int)
(@1, @2 + @3, 5 + (@4 * 2)) = (@2 + @3, 8, @1 - @4)

build-scalar,semtree-expr vars=(int, int, int, int)
((@1, @2), (@3, @4)) = ((1, 2), (3, 4))
----
eq (type: bool)
 ├── tuple (type: tuple{tuple{int, int}, tuple{int, int}})
 │    ├── tuple (type: tuple{int, int})
 │    │    ├── variable (@1) (type: int)
 │    │    └── variable (@2) (type: int)
 │    └── tuple (type: tuple{int, int})
 │         ├── variable (@3) (type: int)
 │         └── variable (@4) (type: int)
 └── tuple (type: tuple{tuple{int, int}, tuple{int, int}})
      ├── tuple (type: tuple{int, int})
      │    ├── const (1) (type: int)
      │    └── const (2) (type: int)
      └── tuple (type: tuple{int, int})
           ├── const (3) (type: int)
           └── const (4) (type: int)
((@1, @2), (@3, @4)) = ((1, 2), (3, 4))

build-scalar,semtree-expr vars=(int, int, int, string)
(@1, (@2, 'a'), (@3, 'b', 5)) = (9, (@1 + @3, @4), (5, @4, @1))
----
eq (type: bool)
 ├── tuple (type: tuple{int, tuple{int, string}, tuple{int, string, int}})
 │    ├── variable (@1) (type: int)
 │    ├── tuple (type: tuple{int, string})
 │    │    ├── variable (@2) (type: int)
 │    │    └── const ('a') (type: string)
 │    └── tuple (type: tuple{int, string, int})
 │         ├── variable (@3) (type: int)
 │         ├── const ('b') (type: string)
 │         └── const (5) (type: int)
 └── tuple (type: tuple{int, tuple{int, string}, tuple{int, string, int}})
      ├── const (9) (type: int)
      ├── tuple (type: tuple{int, string})
      │    ├── plus (type: int)
      │    │    ├── variable (@1) (type: int)
      │    │    └── variable (@3) (type: int)
      │    └── variable (@4) (type: string)
      └── tuple (type: tuple{int, string, int})
           ├── const (5) (type: int)
           ├── variable (@4) (type: string)
           └── variable (@1) (type: int)
(@1, (@2, 'a'), (@3, 'b', 5)) = (9, (@1 + @3, @4), (5, @4, @1))

build-scalar,semtree-expr vars=(int, int)
@1 IS NULL
----
is (type: bool)
 ├── variable (@1) (type: int)
 └── const (NULL) (type: unknown)
@1 IS NULL

build-scalar,semtree-expr vars=(int, int)
@1 IS NOT DISTINCT FROM NULL
----
is (type: bool)
 ├── variable (@1) (type: int)
 └── const (NULL) (type: unknown)
@1 IS NULL

build-scalar,semtree-expr vars=(int, int)
@1 IS NOT DISTINCT FROM @2
----
is (type: bool)
 ├── variable (@1) (type: int)
 └── variable (@2) (type: int)
@1 IS NOT DISTINCT FROM @2

build-scalar,semtree-expr vars=(int, int)
@1 IS NOT NULL
----
is-not (type: bool)
 ├── variable (@1) (type: int)
 └── const (NULL) (type: unknown)
@1 IS NOT NULL

build-scalar,semtree-expr vars=(int, int)
@1 IS DISTINCT FROM NULL
----
is-not (type: bool)
 ├── variable (@1) (type: int)
 └── const (NULL) (type: unknown)
@1 IS NOT NULL

build-scalar,semtree-expr vars=(int, int)
@1 IS DISTINCT FROM @2
----
is-not (type: bool)
 ├── variable (@1) (type: int)
 └── variable (@2) (type: int)
@1 IS DISTINCT FROM @2

build-scalar,semtree-expr vars=(int, int)
+ @1 + (- @2)
----
plus (type: int)
 ├── unary-plus (type: int)
 │    └── variable (@1) (type: int)
 └── unary-minus (type: int)
      └── variable (@2) (type: int)
(+@1) + (-@2)

build-scalar,semtree-expr vars=(int, int)
CASE WHEN @1 = 2 THEN 1 ELSE 2 END
----
unsupported-scalar (CASE WHEN @1 = 2 THEN 1 ELSE 2 END) (type: int)
CASE WHEN @1 = 2 THEN 1 ELSE 2 END

build-scalar,semtree-expr vars=(string)
LENGTH(@1) = 2
----
eq (type: bool)
 ├── unsupported-scalar (length(@1)) (type: int)
 └── const (2) (type: int)
length(@1) = 2

build-scalar,semtree-expr vars=(jsonb)
@1 @> '{"a": 1}'
----
contains (type: bool)
 ├── variable (@1) (type: jsonb)
 └── const ('{"a": 1}') (type: jsonb)
@1 @> '{"a": 1}'

build-scalar,semtree-expr vars=(jsonb)
'{"a": 1}' <@ @1
----
contained-by (type: bool)
 ├── const ('{"a": 1}') (type: jsonb)
 └── variable (@1) (type: jsonb)
'{"a": 1}' <@ @1
