# LogicTest: local-opt

query TTT colnames
EXPLAIN (PLAN) SELECT 1 FROM system.jobs WHERE FALSE
----
tree    field  description
norows  ·      ·

query TTT colnames
EXPLAIN (PLAN) SELECT 1 FROM system.jobs WHERE NULL
----
tree    field  description
norows  ·      ·

query TTT colnames
EXPLAIN (PLAN) SELECT 1 FROM system.jobs WHERE TRUE
----
tree       field  description
render     ·      ·
 └── scan  ·      ·
·          table  jobs@jobs_status_created_idx
·          spans  ALL

query TTTTT colnames
EXPLAIN (PLAN, VERBOSE) SELECT 1 a
----
tree    field          description      columns  ordering
values  ·              ·                (a)      ·
·       size           1 column, 1 row  ·        ·
·       row 0, expr 0  1                ·        ·

query TTTTT colnames
EXPLAIN (VERBOSE,PLAN) SELECT 1 a
----
tree    field          description      columns  ordering
values  ·              ·                (a)      ·
·       size           1 column, 1 row  ·        ·
·       row 0, expr 0  1                ·        ·


query TTTTT colnames
EXPLAIN (TYPES) SELECT 1 a
----
tree    field          description      columns  ordering
values  ·              ·                (a int)  ·
·       size           1 column, 1 row  ·        ·
·       row 0, expr 0  (1)[int]         ·        ·

statement error cannot set EXPLAIN mode more than once
EXPLAIN (PLAN,PLAN) SELECT 1

statement error cannot set EXPLAIN mode more than once
EXPLAIN (PLAN,DISTSQL) SELECT 1

statement error unsupported EXPLAIN option
EXPLAIN (PLAN,UNKNOWN) SELECT 1

statement error could not determine data type of placeholder \$1
EXPLAIN (TYPES) SELECT $1

# TODO(radu): we don't support placeholders with no values.
#query TTTTT colnames
#EXPLAIN (TYPES) SELECT $1::INT AS a
#----
#Tree           Field     Description               Columns          Ordering
#render         ·         ·                         (a int)          a=CONST
# │             render 0  (($1)[string]::INT)[int]  ·                ·
# └── emptyrow  ·         ·                         ()               ·


# Ensure that all relevant statement types can be explained
query TTT
EXPLAIN CREATE DATABASE foo
----
create database  ·  ·

query TTT
EXPLAIN CREATE TABLE foo (x INT)
----
create table  ·  ·

statement ok
CREATE TABLE foo (x INT)

query TTT
EXPLAIN CREATE INDEX a ON foo(x)
----
create index  ·  ·

statement ok
CREATE DATABASE foo

query TTT
EXPLAIN DROP DATABASE foo
----
drop database  ·  ·

# explain SHOW JOBS - beware to test this before the CREATE INDEX
# below, otherwise the result becomes non-deterministic.
# Migrations with backfill will affect the number of rows.
query TTT
SELECT * FROM [EXPLAIN SHOW JOBS] WHERE field != 'size'
----
sort                   ·       ·
 │                     order   -"coalesce",-started
 └── render            ·       ·
      └── filter       ·       ·
           │           filter  ((job_type != 'AUTO CREATE STATS') OR (job_type IS NULL)) AND ((finished IS NULL) OR (finished > (now() - '12:00:00')))
           └── values  ·       ·

statement ok
CREATE INDEX a ON foo(x)

query TTT
EXPLAIN DROP INDEX foo@a
----
drop index  ·  ·

query TTT
EXPLAIN ALTER TABLE foo ADD COLUMN y INT
----
alter table  ·  ·

query TTT
SELECT tree, field, description FROM [EXPLAIN (VERBOSE) ALTER TABLE foo SPLIT AT VALUES (42)]
----
split        ·              ·
 └── values  ·              ·
·            size           1 column, 1 row
·            row 0, expr 0  42

query TTT
EXPLAIN DROP TABLE foo
----
drop table  ·  ·

query TTT
SELECT * FROM [EXPLAIN SHOW DATABASES] WHERE field != 'size'
----
distinct               ·          ·
 │                     order key  database_name
 └── sort              ·          ·
      │                order      +database_name
      └── render       ·          ·
           └── values  ·          ·

query TTT
SELECT * FROM [EXPLAIN SHOW TABLES] WHERE field != 'size'
----
sort                   ·       ·
 │                     order   +table_schema,+table_name
 └── render            ·       ·
      └── filter       ·       ·
           │           filter  table_schema = 'public'
           └── values  ·       ·

query TTT
SELECT * FROM [EXPLAIN SHOW TABLES WITH COMMENT] WHERE field != 'size'
----
render                      ·         ·
 └── hash-join              ·         ·
      │                     type      left outer
      │                     equality  (oid) = (objoid)
      ├── hash-join         ·         ·
      │    │                type      inner
      │    │                equality  (relnamespace) = (oid)
      │    ├── filter       ·         ·
      │    │    │           filter    relkind IN ('r', 'v')
      │    │    └── values  ·         ·
      │    └── filter       ·         ·
      │         │           filter    nspname = 'public'
      │         └── values  ·         ·
      └── filter            ·         ·
           │                filter    objsubid = 0
           └── values       ·         ·

query TTT
SELECT * FROM [EXPLAIN SHOW DATABASE] WHERE field != 'size'
----
render            ·       ·
 └── filter       ·       ·
      │           filter  variable = 'database'
      └── values  ·       ·

query TTT
SELECT * FROM [EXPLAIN SHOW TIME ZONE] WHERE field != 'size'
----
render            ·       ·
 └── filter       ·       ·
      │           filter  variable = 'timezone'
      └── values  ·       ·

query TTT
SELECT * FROM [EXPLAIN SHOW DEFAULT_TRANSACTION_ISOLATION] WHERE field != 'size'
----
render            ·       ·
 └── filter       ·       ·
      │           filter  variable = 'default_transaction_isolation'
      └── values  ·       ·

query TTT
SELECT * FROM [EXPLAIN SHOW TRANSACTION ISOLATION LEVEL] WHERE field != 'size'
----
render            ·       ·
 └── filter       ·       ·
      │           filter  variable = 'transaction_isolation'
      └── values  ·       ·

query TTT
SELECT * FROM [EXPLAIN SHOW TRANSACTION PRIORITY] WHERE field != 'size'
----
render            ·       ·
 └── filter       ·       ·
      │           filter  variable = 'transaction_priority'
      └── values  ·       ·

query TTT
SELECT * FROM [EXPLAIN SHOW COLUMNS FROM foo] WHERE field != 'size'
----
sort                                       ·            ·
 │                                         order        +ordinal_position
 └── render                                ·            ·
      └── group                            ·            ·
           │                               aggregate 0  column_name
           │                               aggregate 1  crdb_sql_type
           │                               aggregate 2  is_nullable
           │                               aggregate 3  column_default
           │                               aggregate 4  generation_expression
           │                               aggregate 5  ordinal_position
           │                               aggregate 6  is_hidden
           │                               aggregate 7  array_agg(index_name)
           │                               group by     @1-@7
           └── render                      ·            ·
                └── hash-join              ·            ·
                     │                     type         left outer
                     │                     equality     (column_name) = (column_name)
                     ├── render            ·            ·
                     │    └── filter       ·            ·
                     │         │           filter       ((table_catalog = 'test') AND (table_schema = 'public')) AND (table_name = 'foo')
                     │         └── values  ·            ·
                     └── render            ·            ·
                          └── filter       ·            ·
                               │           filter       ((table_catalog = 'test') AND (table_schema = 'public')) AND (table_name = 'foo')
                               └── values  ·            ·

query TTT
SELECT * FROM [EXPLAIN SHOW GRANTS ON foo] WHERE field != 'size'
----
sort                   ·       ·
 │                     order   +database_name,+schema_name,+table_name,+grantee,+privilege_type
 └── render            ·       ·
      └── filter       ·       ·
           │           filter  (table_catalog, table_schema, table_name) IN (('test', 'public', 'foo'),)
           └── values  ·       ·

query TTT
SELECT * FROM [EXPLAIN SHOW INDEX FROM foo] WHERE field != 'size'
----
render            ·       ·
 └── filter       ·       ·
      │           filter  ((table_catalog = 'test') AND (table_schema = 'public')) AND (table_name = 'foo')
      └── values  ·       ·

query TTT
SELECT * FROM [EXPLAIN SHOW CONSTRAINTS FROM foo] WHERE field != 'size'
----
sort                             ·         ·
 │                               order     +table_name,+constraint_name
 └── render                      ·         ·
      └── hash-join              ·         ·
           │                     type      inner
           │                     equality  (relnamespace, oid) = (oid, conrelid)
           ├── filter            ·         ·
           │    │                filter    relname = 'foo'
           │    └── values       ·         ·
           └── hash-join         ·         ·
                │                type      cross
                ├── filter       ·         ·
                │    │           filter    nspname = 'public'
                │    └── values  ·         ·
                └── values       ·         ·

query TTT
EXPLAIN SHOW USERS
----
render     ·       ·
 └── scan  ·       ·
·          table   users@primary
·          spans   ALL
·          filter  "isRole" = false

# EXPLAIN selecting from a sequence.
statement ok
CREATE SEQUENCE select_test

query TTTTT colnames
EXPLAIN (VERBOSE) SELECT * FROM select_test
----
tree             field  description  columns                           ordering
sequence select  ·      ·            (last_value, log_cnt, is_called)  ·

query TTTTT colnames
EXPLAIN (VERBOSE) SELECT @1 FROM select_test
----
tree                  field     description  columns                           ordering
render                ·         ·            ("?column?")                      ·
 │                    render 0  last_value   ·                                 ·
 └── sequence select  ·         ·            (last_value, log_cnt, is_called)  ·

statement ok
CREATE TABLE t (
  k INT PRIMARY KEY,
  v INT
)

query TTT
EXPLAIN INSERT INTO t VALUES (1, 2)
----
count             ·         ·
 └── insert       ·         ·
      │           into      t(k, v)
      │           strategy  inserter
      └── values  ·         ·
·                 size      2 columns, 1 row

query I
SELECT max(level) FROM [EXPLAIN (VERBOSE) INSERT INTO t VALUES (1, 2)]
----
2

statement ok
INSERT INTO t VALUES (1, 2)

query TTT
EXPLAIN SELECT * FROM t
----
scan  ·      ·
·     table  t@primary
·     spans  ALL

query TTTTT
EXPLAIN (VERBOSE) SELECT * FROM t
----
scan  ·      ·          (k, v)  ·
·     table  t@primary  ·       ·
·     spans  ALL        ·       ·

query TTT
EXPLAIN SELECT * FROM t WHERE k = 1 OR k = 3
----
scan  ·         ·
·     table     t@primary
·     spans     /1-/1/# /3-/3/#
·     parallel  ·

query TTTTT
EXPLAIN (VERBOSE) SELECT * FROM t WHERE k % 2 = 0
----
scan  ·       ·            (k, v)  ·
·     table   t@primary    ·       ·
·     spans   ALL          ·       ·
·     filter  (k % 2) = 0  ·       ·

query TTT
EXPLAIN VALUES (1, 2, 3), (4, 5, 6)
----
values  ·     ·
·       size  3 columns, 2 rows

query TTT
EXPLAIN VALUES (1)
----
values  ·     ·
·       size  1 column, 1 row

query TTT
SELECT tree, field, description FROM [EXPLAIN (VERBOSE) SELECT * FROM t WITH ORDINALITY LIMIT 1 OFFSET 1]
----
limit            ·       ·
 │               count   1
 │               offset  1
 └── ordinality  ·       ·
      └── scan   ·       ·
·                table   t@primary
·                spans   ALL

query TTT
EXPLAIN SELECT DISTINCT v FROM t
----
distinct   ·            ·
 │         distinct on  v
 └── scan  ·            ·
·          table        t@primary
·          spans        ALL

query TTT
SELECT tree, field, description FROM [EXPLAIN (VERBOSE) SELECT DISTINCT v FROM t LIMIT 1 OFFSET 1]
----
limit           ·            ·
 │              count        1
 │              offset       1
 └── distinct   ·            ·
      │         distinct on  v
      └── scan  ·            ·
·               table        t@primary
·               spans        ALL

statement ok
CREATE TABLE tc (a INT, b INT, INDEX c(a))

query TTTTT
EXPLAIN (VERBOSE) SELECT * FROM tc WHERE a = 10 ORDER BY b
----
sort             ·      ·           (a, b)              +b
 │               order  +b          ·                   ·
 └── index-join  ·      ·           (a, b)              ·
      │          table  tc@primary  ·                   ·
      └── scan   ·      ·           (a, rowid[hidden])  ·
·                table  tc@c        ·                   ·
·                spans  /10-/11     ·                   ·

query TTTTT colnames
EXPLAIN (TYPES) INSERT INTO t VALUES (1, 2)
----
tree              field          description       columns                     ordering
count             ·              ·                 ()                          ·
 └── insert       ·              ·                 ()                          ·
      │           into           t(k, v)           ·                           ·
      │           strategy       inserter          ·                           ·
      └── values  ·              ·                 (column1 int, column2 int)  ·
·                 size           2 columns, 1 row  ·                           ·
·                 row 0, expr 0  (1)[int]          ·                           ·
·                 row 0, expr 1  (2)[int]          ·                           ·

query TTTTT
EXPLAIN (TYPES) SELECT 42 AS a
----
values  ·              ·                (a int)  ·
·       size           1 column, 1 row  ·        ·
·       row 0, expr 0  (42)[int]        ·        ·

query TTTTT
EXPLAIN (TYPES) SELECT * FROM t
----
scan  ·      ·          (k int, v int)  ·
·     table  t@primary  ·               ·
·     spans  ALL        ·               ·

query TTTTT
EXPLAIN (TYPES,SYMVARS) SELECT k FROM t
----
scan  ·      ·          (k int)  ·
·     table  t@primary  ·        ·
·     spans  ALL        ·        ·

query TTTTT
EXPLAIN (TYPES,VERBOSE) SELECT k FROM t
----
scan  ·      ·          (k int)  ·
·     table  t@primary  ·        ·
·     spans  ALL        ·        ·

query TTTTT
EXPLAIN (TYPES) SELECT * FROM t WHERE v > 123
----
scan  ·       ·                              (k int, v int)  ·
·     table   t@primary                      ·               ·
·     spans   ALL                            ·               ·
·     filter  ((v)[int] > (123)[int])[bool]  ·               ·

query TTTTT
EXPLAIN (TYPES) VALUES (1, 2, 3), (4, 5, 6)
----
values  ·              ·                  (column1 int, column2 int, column3 int)  ·
·       size           3 columns, 2 rows  ·                                        ·
·       row 0, expr 0  (1)[int]           ·                                        ·
·       row 0, expr 1  (2)[int]           ·                                        ·
·       row 0, expr 2  (3)[int]           ·                                        ·
·       row 1, expr 0  (4)[int]           ·                                        ·
·       row 1, expr 1  (5)[int]           ·                                        ·
·       row 1, expr 2  (6)[int]           ·                                        ·

query TTTTT
EXPLAIN (TYPES) SELECT 2*count(k) as z, v FROM t WHERE v>123 GROUP BY v HAVING v<2 AND count(k)>1
----
render       ·         ·         (z int, v int)  ·
 │           render 0  (z)[int]  ·               ·
 │           render 1  (v)[int]  ·               ·
 └── norows  ·         ·         (v int, z int)  ·

query TTTTT
EXPLAIN (TYPES) DELETE FROM t WHERE v > 1
----
count                ·         ·                            ()              ·
 └── delete          ·         ·                            ()              ·
      │              from      t                            ·               ·
      │              strategy  deleter                      ·               ·
      └── render     ·         ·                            (k int)         ·
           │         render 0  (k)[int]                     ·               ·
           └── scan  ·         ·                            (k int, v int)  ·
·                    table     t@primary                    ·               ·
·                    spans     ALL                          ·               ·
·                    filter    ((v)[int] > (1)[int])[bool]  ·               ·

query TTTTT
EXPLAIN (TYPES) UPDATE t SET v = k + 1 WHERE v > 123
----
count                ·         ·                              ()                           ·
 └── update          ·         ·                              ()                           ·
      │              table     t                              ·                            ·
      │              set       v                              ·                            ·
      │              strategy  updater                        ·                            ·
      └── render     ·         ·                              (k int, v int, column5 int)  ·
           │         render 0  (k)[int]                       ·                            ·
           │         render 1  (v)[int]                       ·                            ·
           │         render 2  ((k)[int] + (1)[int])[int]     ·                            ·
           └── scan  ·         ·                              (k int, v int)               ·
·                    table     t@primary                      ·                            ·
·                    spans     ALL                            ·                            ·
·                    filter    ((v)[int] > (123)[int])[bool]  ·                            ·

query TTTTT
EXPLAIN (TYPES) VALUES (1) UNION VALUES (2)
----
union        ·              ·                (column1 int)  ·
 ├── values  ·              ·                (column1 int)  ·
 │           size           1 column, 1 row  ·              ·
 │           row 0, expr 0  (2)[int]         ·              ·
 └── values  ·              ·                (column1 int)  ·
·            size           1 column, 1 row  ·              ·
·            row 0, expr 0  (1)[int]         ·              ·

query TTTTT
EXPLAIN (TYPES) SELECT DISTINCT k FROM t
----
scan  ·      ·          (k int)  ·
·     table  t@primary  ·        ·
·     spans  ALL        ·        ·

query TTTTT
EXPLAIN (TYPES) SELECT v FROM t ORDER BY v
----
sort       ·      ·          (v int)  +v
 │         order  +v         ·        ·
 └── scan  ·      ·          (v int)  ·
·          table  t@primary  ·        ·
·          spans  ALL        ·        ·

query TTTTT
EXPLAIN (TYPES) SELECT v FROM t LIMIT 1
----
scan  ·      ·          (v int)  ·
·     table  t@primary  ·        ·
·     spans  ALL        ·        ·
·     limit  1          ·        ·

statement ok
CREATE TABLE tt (x INT, y INT, INDEX a(x), INDEX b(y))

query TTTTT
EXPLAIN (TYPES) SELECT * FROM tt WHERE x < 10 AND y > 10
----
scan  ·       ·                                                                          (x int, y int)  ·
·     table   tt@primary                                                                 ·               ·
·     spans   ALL                                                                        ·               ·
·     filter  ((((x)[int] < (10)[int])[bool]) AND (((y)[int] > (10)[int])[bool]))[bool]  ·               ·

# TODO(radu): we don't support placeholders with no values.
#query TTTTT
#EXPLAIN (TYPES) SELECT $1 + 2 AS a
#----
#render         ·         ·                            (a int)  a=CONST
# │             render 0  (($1)[int] + (2)[int])[int]  ·        ·
# └── emptyrow  ·         ·                            ()       ·

query TTTTT
EXPLAIN (TYPES) SELECT abs(2-3) AS a
----
values  ·              ·                (a int)  ·
·       size           1 column, 1 row  ·        ·
·       row 0, expr 0  (1)[int]         ·        ·

# Check array subscripts (#13811)
query TTTTT
EXPLAIN (TYPES) SELECT x[1] FROM (SELECT ARRAY[1,2,3] AS x)
----
values  ·              ·                (x int)  ·
·       size           1 column, 1 row  ·        ·
·       row 0, expr 0  (1)[int]         ·        ·

query T
EXPLAIN (OPT) SELECT 1 AS r
----
values
 └── (1,)

query T
EXPLAIN (OPT,VERBOSE) SELECT 1 AS r
----
values
 ├── columns: r:1
 ├── cardinality: [1 - 1]
 ├── stats: [rows=1]
 ├── cost: 0.02
 ├── key: ()
 ├── fd: ()-->(1)
 ├── prune: (1)
 └── (1,)

query T
EXPLAIN (OPT,TYPES) SELECT 1 AS r
----
values
 ├── columns: r:1(int)
 ├── cardinality: [1 - 1]
 ├── stats: [rows=1]
 ├── cost: 0.02
 ├── key: ()
 ├── fd: ()-->(1)
 ├── prune: (1)
 └── tuple [type=tuple{int}]
      └── const: 1 [type=int]

query T
EXPLAIN (OPT) SELECT * FROM tc WHERE a = 10 ORDER BY b
----
sort
 └── index-join tc
      └── scan tc@c
           └── constraint: /1/3: [/10 - /10]

query T
EXPLAIN (OPT,VERBOSE) SELECT * FROM tc WHERE a = 10 ORDER BY b
----
sort
 ├── columns: a:1 b:2
 ├── stats: [rows=9.9, distinct(1)=1, null(1)=0]
 ├── cost: 52.2638708
 ├── fd: ()-->(1)
 ├── ordering: +2 opt(1) [actual: +2]
 ├── prune: (2)
 └── index-join tc
      ├── columns: a:1 b:2
      ├── stats: [rows=9.9, distinct(1)=1, null(1)=0]
      ├── cost: 51.401
      ├── fd: ()-->(1)
      ├── prune: (2)
      └── scan tc@c
           ├── columns: a:1 rowid:3
           ├── constraint: /1/3: [/10 - /10]
           ├── stats: [rows=9.9, distinct(1)=1, null(1)=0, distinct(3)=9.9, null(3)=0]
           ├── cost: 10.702
           ├── key: (3)
           └── fd: ()-->(1)

query T
EXPLAIN (OPT,TYPES) SELECT * FROM tc WHERE a = 10 ORDER BY b
----
sort
 ├── columns: a:1(int!null) b:2(int)
 ├── stats: [rows=9.9, distinct(1)=1, null(1)=0]
 ├── cost: 52.2638708
 ├── fd: ()-->(1)
 ├── ordering: +2 opt(1) [actual: +2]
 ├── prune: (2)
 └── index-join tc
      ├── columns: a:1(int!null) b:2(int)
      ├── stats: [rows=9.9, distinct(1)=1, null(1)=0]
      ├── cost: 51.401
      ├── fd: ()-->(1)
      ├── prune: (2)
      └── scan tc@c
           ├── columns: a:1(int!null) rowid:3(int!null)
           ├── constraint: /1/3: [/10 - /10]
           ├── stats: [rows=9.9, distinct(1)=1, null(1)=0, distinct(3)=9.9, null(3)=0]
           ├── cost: 10.702
           ├── key: (3)
           └── fd: ()-->(1)

query T
EXPLAIN (OPT) SELECT * FROM tc WHERE a + 2 * b > 1 ORDER BY a*b
----
sort
 └── project
      ├── select
      │    ├── scan tc
      │    └── filters
      │         └── (a + (b * 2)) > 1
      └── projections
           └── a * b

query T
EXPLAIN (OPT, VERBOSE) SELECT * FROM tc WHERE a + 2 * b > 1 ORDER BY a*b
----
sort
 ├── columns: a:1 b:2  [hidden: column4:4]
 ├── stats: [rows=333.333333]
 ├── cost: 1179.25548
 ├── fd: (1,2)-->(4)
 ├── ordering: +4
 ├── prune: (1,2,4)
 └── project
      ├── columns: column4:4 a:1 b:2
      ├── stats: [rows=333.333333]
      ├── cost: 1116.70667
      ├── fd: (1,2)-->(4)
      ├── prune: (1,2,4)
      ├── select
      │    ├── columns: a:1 b:2
      │    ├── stats: [rows=333.333333]
      │    ├── cost: 1110.03
      │    ├── scan tc
      │    │    ├── columns: a:1 b:2
      │    │    ├── stats: [rows=1000]
      │    │    ├── cost: 1100.02
      │    │    └── prune: (1,2)
      │    └── filters
      │         └── (a + (b * 2)) > 1 [outer=(1,2)]
      └── projections
           └── a * b [outer=(1,2)]

query T
EXPLAIN (OPT, TYPES) SELECT * FROM tc WHERE a + 2 * b > 1 ORDER BY a*b
----
sort
 ├── columns: a:1(int) b:2(int)  [hidden: column4:4(int)]
 ├── stats: [rows=333.333333]
 ├── cost: 1179.25548
 ├── fd: (1,2)-->(4)
 ├── ordering: +4
 ├── prune: (1,2,4)
 └── project
      ├── columns: column4:4(int) a:1(int) b:2(int)
      ├── stats: [rows=333.333333]
      ├── cost: 1116.70667
      ├── fd: (1,2)-->(4)
      ├── prune: (1,2,4)
      ├── select
      │    ├── columns: a:1(int) b:2(int)
      │    ├── stats: [rows=333.333333]
      │    ├── cost: 1110.03
      │    ├── scan tc
      │    │    ├── columns: a:1(int) b:2(int)
      │    │    ├── stats: [rows=1000]
      │    │    ├── cost: 1100.02
      │    │    └── prune: (1,2)
      │    └── filters
      │         └── gt [type=bool, outer=(1,2)]
      │              ├── plus [type=int]
      │              │    ├── variable: a [type=int]
      │              │    └── mult [type=int]
      │              │         ├── variable: b [type=int]
      │              │         └── const: 2 [type=int]
      │              └── const: 1 [type=int]
      └── projections
           └── mult [type=int, outer=(1,2)]
                ├── variable: a [type=int]
                └── variable: b [type=int]

# Test with an unsupported statement.
statement error window functions are not supported
EXPLAIN (OPT) SELECT avg(x) OVER () FROM (VALUES (1)) AS t(x)
