build-scalar
1
----
const: 1 [type=int]

build-scalar
1 + 2
----
plus [type=int]
 ├── const: 1 [type=int]
 └── const: 2 [type=int]

build-scalar vars=(string)
@1
----
variable: @1 [type=string]

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

build-scalar 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]

build-scalar 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]

build-scalar 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]

build-scalar 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]

build-scalar 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]

build-scalar 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]

build-scalar 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]

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

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

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

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

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

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

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

build-scalar vars=(int, int)
CASE WHEN @1 = 2 THEN 1 ELSE 2 END
----
error: not yet implemented: scalar expr: *tree.CaseExpr


build-scalar vars=(string)
LENGTH(@1) = 2
----
eq [type=bool]
 ├── function: length [type=unknown]
 │    └── variable: @1 [type=string]
 └── const: 2 [type=int]


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


build-scalar vars=(jsonb)
'{"a":1}' <@ @1
----
contains [type=bool]
 ├── variable: @1 [type=jsonb]
 └── const: '{"a": 1}' [type=jsonb]


build-scalar
TRUE
----
true [type=bool]


build-scalar
FALSE
----
false [type=bool]
