exec-ddl
CREATE TABLE t (a INT, b INT, k INT PRIMARY KEY)
----
TABLE t
 ├── a int
 ├── b int
 ├── k int not null
 └── INDEX primary
      └── k int not null

opt format=show-all
SELECT a + 1, min(b) FROM t WHERE k + a > b GROUP BY a ORDER BY a
----
sort
 ├── columns: "?column?":5(int) min:4(int)  [hidden: t.public.t.a:1(int)]
 ├── stats: [rows=98.1771622]
 ├── cost: 1097.86224
 ├── key: (1)
 ├── fd: (1)-->(4,5)
 ├── ordering: +1
 ├── prune: (1,4,5)
 └── project
      ├── columns: "?column?":5(int) t.public.t.a:1(int) min:4(int)
      ├── stats: [rows=98.1771622]
      ├── cost: 1082.89531
      ├── key: (1)
      ├── fd: (1)-->(4,5)
      ├── prune: (1,4,5)
      ├── group-by
      │    ├── columns: t.public.t.a:1(int) min:4(int)
      │    ├── grouping columns: t.public.t.a:1(int)
      │    ├── stats: [rows=98.1771622, distinct(1)=98.1771622, null(1)=3.3]
      │    ├── cost: 1080.92177
      │    ├── key: (1)
      │    ├── fd: (1)-->(4)
      │    ├── prune: (4)
      │    ├── select
      │    │    ├── columns: t.public.t.a:1(int) t.public.t.b:2(int!null) t.public.t.k:3(int!null)
      │    │    ├── stats: [rows=330, distinct(1)=98.1771622, null(1)=3.3, distinct(2)=98.265847, null(2)=0, distinct(3)=330, null(3)=0]
      │    │    ├── cost: 1070.03
      │    │    ├── key: (3)
      │    │    ├── fd: (3)-->(1,2)
      │    │    ├── interesting orderings: (+3)
      │    │    ├── scan t.public.t
      │    │    │    ├── columns: t.public.t.a:1(int) t.public.t.b:2(int) t.public.t.k:3(int!null)
      │    │    │    ├── stats: [rows=1000, distinct(1)=100, null(1)=10, distinct(2)=100, null(2)=10, distinct(3)=1000, null(3)=0]
      │    │    │    ├── cost: 1060.02
      │    │    │    ├── key: (3)
      │    │    │    ├── fd: (3)-->(1,2)
      │    │    │    ├── prune: (1-3)
      │    │    │    └── interesting orderings: (+3)
      │    │    └── filters
      │    │         └── lt [type=bool, outer=(1-3), constraints=(/2: (/NULL - ])]
      │    │              ├── variable: t.public.t.b [type=int]
      │    │              └── plus [type=int]
      │    │                   ├── variable: t.public.t.k [type=int]
      │    │                   └── variable: t.public.t.a [type=int]
      │    └── aggregations
      │         └── min [type=int, outer=(2)]
      │              └── variable: t.public.t.b [type=int]
      └── projections
           └── plus [type=int, outer=(1)]
                ├── variable: t.public.t.a [type=int]
                └── const: 1 [type=int]

opt format=(hide-miscprops,hide-constraints,hide-funcdeps,hide-ruleprops)
SELECT a + 1, min(b) FROM t WHERE k + a > b GROUP BY a ORDER BY a
----
sort
 ├── columns: "?column?":5(int) min:4(int)  [hidden: t.public.t.a:1(int)]
 ├── stats: [rows=98.1771622]
 ├── cost: 1097.86224
 ├── ordering: +1
 └── project
      ├── columns: "?column?":5(int) t.public.t.a:1(int) min:4(int)
      ├── stats: [rows=98.1771622]
      ├── cost: 1082.89531
      ├── group-by
      │    ├── columns: t.public.t.a:1(int) min:4(int)
      │    ├── grouping columns: t.public.t.a:1(int)
      │    ├── stats: [rows=98.1771622, distinct(1)=98.1771622, null(1)=3.3]
      │    ├── cost: 1080.92177
      │    ├── select
      │    │    ├── columns: t.public.t.a:1(int) t.public.t.b:2(int!null) t.public.t.k:3(int!null)
      │    │    ├── stats: [rows=330, distinct(1)=98.1771622, null(1)=3.3, distinct(2)=98.265847, null(2)=0, distinct(3)=330, null(3)=0]
      │    │    ├── cost: 1070.03
      │    │    ├── scan t.public.t
      │    │    │    ├── columns: t.public.t.a:1(int) t.public.t.b:2(int) t.public.t.k:3(int!null)
      │    │    │    ├── stats: [rows=1000, distinct(1)=100, null(1)=10, distinct(2)=100, null(2)=10, distinct(3)=1000, null(3)=0]
      │    │    │    └── cost: 1060.02
      │    │    └── filters
      │    │         └── lt [type=bool]
      │    │              ├── variable: t.public.t.b [type=int]
      │    │              └── plus [type=int]
      │    │                   ├── variable: t.public.t.k [type=int]
      │    │                   └── variable: t.public.t.a [type=int]
      │    └── aggregations
      │         └── min [type=int]
      │              └── variable: t.public.t.b [type=int]
      └── projections
           └── plus [type=int]
                ├── variable: t.public.t.a [type=int]
                └── const: 1 [type=int]

opt format=(hide-stats,hide-cost,hide-qual,hide-scalars)
SELECT a + 1, min(b) FROM t WHERE k + a > b GROUP BY a ORDER BY a
----
sort
 ├── columns: "?column?":5(int) min:4(int)  [hidden: a:1(int)]
 ├── key: (1)
 ├── fd: (1)-->(4,5)
 ├── ordering: +1
 ├── prune: (1,4,5)
 └── project
      ├── columns: "?column?":5(int) a:1(int) min:4(int)
      ├── key: (1)
      ├── fd: (1)-->(4,5)
      ├── prune: (1,4,5)
      ├── group-by
      │    ├── columns: a:1(int) min:4(int)
      │    ├── grouping columns: a:1(int)
      │    ├── key: (1)
      │    ├── fd: (1)-->(4)
      │    ├── prune: (4)
      │    ├── select
      │    │    ├── columns: a:1(int) b:2(int!null) k:3(int!null)
      │    │    ├── key: (3)
      │    │    ├── fd: (3)-->(1,2)
      │    │    ├── interesting orderings: (+3)
      │    │    ├── scan t
      │    │    │    ├── columns: a:1(int) b:2(int) k:3(int!null)
      │    │    │    ├── key: (3)
      │    │    │    ├── fd: (3)-->(1,2)
      │    │    │    ├── prune: (1-3)
      │    │    │    └── interesting orderings: (+3)
      │    │    └── filters
      │    │         └── b < (k + a) [type=bool, outer=(1-3), constraints=(/2: (/NULL - ])]
      │    └── aggregations
      │         └── min [type=int, outer=(2)]
      │              └── variable: b [type=int]
      └── projections
           └── a + 1 [type=int, outer=(1)]

opt format=(hide-stats,hide-cost,hide-qual,hide-scalars,hide-types)
SELECT a + 1, min(b) FROM t WHERE k + a > b GROUP BY a ORDER BY a
----
sort
 ├── columns: "?column?":5 min:4  [hidden: a:1]
 ├── key: (1)
 ├── fd: (1)-->(4,5)
 ├── ordering: +1
 ├── prune: (1,4,5)
 └── project
      ├── columns: "?column?":5 a:1 min:4
      ├── key: (1)
      ├── fd: (1)-->(4,5)
      ├── prune: (1,4,5)
      ├── group-by
      │    ├── columns: a:1 min:4
      │    ├── grouping columns: a:1
      │    ├── key: (1)
      │    ├── fd: (1)-->(4)
      │    ├── prune: (4)
      │    ├── select
      │    │    ├── columns: a:1 b:2 k:3
      │    │    ├── key: (3)
      │    │    ├── fd: (3)-->(1,2)
      │    │    ├── interesting orderings: (+3)
      │    │    ├── scan t
      │    │    │    ├── columns: a:1 b:2 k:3
      │    │    │    ├── key: (3)
      │    │    │    ├── fd: (3)-->(1,2)
      │    │    │    ├── prune: (1-3)
      │    │    │    └── interesting orderings: (+3)
      │    │    └── filters
      │    │         └── b < (k + a) [outer=(1-3), constraints=(/2: (/NULL - ])]
      │    └── aggregations
      │         └── min [outer=(2)]
      │              └── variable: b
      └── projections
           └── a + 1 [outer=(1)]

opt format=(hide-miscprops,hide-orderings,hide-columns)
SELECT a + 1, min(b) FROM t WHERE k + a > b GROUP BY a ORDER BY a
----
sort
 ├── stats: [rows=98.1771622]
 ├── cost: 1097.86224
 ├── key: (1)
 ├── fd: (1)-->(4,5)
 ├── prune: (1,4,5)
 └── project
      ├── stats: [rows=98.1771622]
      ├── cost: 1082.89531
      ├── key: (1)
      ├── fd: (1)-->(4,5)
      ├── prune: (1,4,5)
      ├── group-by
      │    ├── stats: [rows=98.1771622, distinct(1)=98.1771622, null(1)=3.3]
      │    ├── cost: 1080.92177
      │    ├── key: (1)
      │    ├── fd: (1)-->(4)
      │    ├── prune: (4)
      │    ├── select
      │    │    ├── stats: [rows=330, distinct(1)=98.1771622, null(1)=3.3, distinct(2)=98.265847, null(2)=0, distinct(3)=330, null(3)=0]
      │    │    ├── cost: 1070.03
      │    │    ├── key: (3)
      │    │    ├── fd: (3)-->(1,2)
      │    │    ├── interesting orderings: (+3)
      │    │    ├── scan t.public.t
      │    │    │    ├── stats: [rows=1000, distinct(1)=100, null(1)=10, distinct(2)=100, null(2)=10, distinct(3)=1000, null(3)=0]
      │    │    │    ├── cost: 1060.02
      │    │    │    ├── key: (3)
      │    │    │    ├── fd: (3)-->(1,2)
      │    │    │    ├── prune: (1-3)
      │    │    │    └── interesting orderings: (+3)
      │    │    └── filters
      │    │         └── lt [type=bool, constraints=(/2: (/NULL - ])]
      │    │              ├── variable: t.public.t.b [type=int]
      │    │              └── plus [type=int]
      │    │                   ├── variable: t.public.t.k [type=int]
      │    │                   └── variable: t.public.t.a [type=int]
      │    └── aggregations
      │         └── min [type=int]
      │              └── variable: t.public.t.b [type=int]
      └── projections
           └── plus [type=int]
                ├── variable: t.public.t.a [type=int]
                └── const: 1 [type=int]

opt format=hide-all
SELECT a + 1, min(b) FROM t WHERE k + a > b GROUP BY a ORDER BY a
----
sort
 └── project
      ├── group-by
      │    ├── select
      │    │    ├── scan t
      │    │    └── filters
      │    │         └── b < (k + a)
      │    └── aggregations
      │         └── min
      │              └── variable: b
      └── projections
           └── a + 1
