exec-ddl
CREATE TABLE t (
  k INT PRIMARY KEY,
  i INT,
  s STRING
)
----

exec-ddl
ALTER TABLE t INJECT STATISTICS '[
  {
    "columns": ["k"],
    "created_at": "2018-01-01 1:00:00.00000+00:00",
    "row_count": 10000,
    "distinct_count": 10000
  },
  {
    "columns": ["i"],
    "created_at": "2018-01-01 1:30:00.00000+00:00",
    "row_count": 10000,
    "distinct_count": 1000
  },
  {
    "columns": ["s"],
    "created_at": "2018-01-01 1:30:00.00000+00:00",
    "row_count": 10000,
    "distinct_count": 100
  }
]'
----

norm
SELECT * FROM t WHERE k = $1
----
select
 ├── columns: k:1(int!null) i:2(int) s:3(string)
 ├── cardinality: [0 - 1]
 ├── has-placeholder
 ├── stats: [rows=1, distinct(1)=1, null(1)=0]
 ├── key: ()
 ├── fd: ()-->(1-3)
 ├── scan t
 │    ├── columns: k:1(int!null) i:2(int) s:3(string)
 │    ├── stats: [rows=10000, distinct(1)=10000, null(1)=0]
 │    ├── key: (1)
 │    └── fd: (1)-->(2,3)
 └── filters
      └── k:1 = $1 [type=bool, outer=(1), constraints=(/1: (/NULL - ]), fd=()-->(1)]

norm
SELECT * FROM t WHERE i = $1
----
select
 ├── columns: k:1(int!null) i:2(int!null) s:3(string)
 ├── has-placeholder
 ├── stats: [rows=10, distinct(2)=1, null(2)=0]
 ├── key: (1)
 ├── fd: ()-->(2), (1)-->(3)
 ├── scan t
 │    ├── columns: k:1(int!null) i:2(int) s:3(string)
 │    ├── stats: [rows=10000, distinct(1)=10000, null(1)=0, distinct(2)=1000, null(2)=0]
 │    ├── key: (1)
 │    └── fd: (1)-->(2,3)
 └── filters
      └── i:2 = $1 [type=bool, outer=(2), constraints=(/2: (/NULL - ]), fd=()-->(2)]

norm
SELECT * FROM t WHERE $1 = s
----
select
 ├── columns: k:1(int!null) i:2(int) s:3(string!null)
 ├── has-placeholder
 ├── stats: [rows=100, distinct(3)=1, null(3)=0]
 ├── key: (1)
 ├── fd: ()-->(3), (1)-->(2)
 ├── scan t
 │    ├── columns: k:1(int!null) i:2(int) s:3(string)
 │    ├── stats: [rows=10000, distinct(1)=10000, null(1)=0, distinct(3)=100, null(3)=0]
 │    ├── key: (1)
 │    └── fd: (1)-->(2,3)
 └── filters
      └── s:3 = $1 [type=bool, outer=(3), constraints=(/3: (/NULL - ]), fd=()-->(3)]

norm
SELECT * FROM t WHERE i = $1 AND s = $2
----
select
 ├── columns: k:1(int!null) i:2(int!null) s:3(string!null)
 ├── has-placeholder
 ├── stats: [rows=0.100001, distinct(2)=0.100001, null(2)=0, distinct(3)=0.100001, null(3)=0, distinct(2,3)=0.100001, null(2,3)=0]
 ├── key: (1)
 ├── fd: ()-->(2,3)
 ├── scan t
 │    ├── columns: k:1(int!null) i:2(int) s:3(string)
 │    ├── stats: [rows=10000, distinct(1)=10000, null(1)=0, distinct(2)=1000, null(2)=0, distinct(3)=100, null(3)=0, distinct(2,3)=10000, null(2,3)=0]
 │    ├── key: (1)
 │    └── fd: (1)-->(2,3)
 └── filters
      ├── i:2 = $1 [type=bool, outer=(2), constraints=(/2: (/NULL - ]), fd=()-->(2)]
      └── s:3 = $2 [type=bool, outer=(3), constraints=(/3: (/NULL - ]), fd=()-->(3)]

norm
SELECT * FROM t WHERE i > $1
----
select
 ├── columns: k:1(int!null) i:2(int!null) s:3(string)
 ├── has-placeholder
 ├── stats: [rows=3333.333, distinct(2)=1000, null(2)=0]
 ├── key: (1)
 ├── fd: (1)-->(2,3)
 ├── scan t
 │    ├── columns: k:1(int!null) i:2(int) s:3(string)
 │    ├── stats: [rows=10000, distinct(1)=10000, null(1)=0, distinct(2)=1000, null(2)=0]
 │    ├── key: (1)
 │    └── fd: (1)-->(2,3)
 └── filters
      └── i:2 > $1 [type=bool, outer=(2), constraints=(/2: (/NULL - ])]

norm
SELECT * FROM t WHERE i = $1 OR i = $2
----
select
 ├── columns: k:1(int!null) i:2(int!null) s:3(string)
 ├── has-placeholder
 ├── stats: [rows=3333.333, distinct(2)=1000, null(2)=0]
 ├── key: (1)
 ├── fd: (1)-->(2,3)
 ├── scan t
 │    ├── columns: k:1(int!null) i:2(int) s:3(string)
 │    ├── stats: [rows=10000, distinct(1)=10000, null(1)=0, distinct(2)=1000, null(2)=0]
 │    ├── key: (1)
 │    └── fd: (1)-->(2,3)
 └── filters
      └── (i:2 = $1) OR (i:2 = $2) [type=bool, outer=(2), constraints=(/2: (/NULL - ])]

norm
SELECT * FROM t WHERE i IN ($1, $2, $3)
----
select
 ├── columns: k:1(int!null) i:2(int) s:3(string)
 ├── has-placeholder
 ├── stats: [rows=3333.333]
 ├── key: (1)
 ├── fd: (1)-->(2,3)
 ├── scan t
 │    ├── columns: k:1(int!null) i:2(int) s:3(string)
 │    ├── stats: [rows=10000, distinct(1)=10000, null(1)=0]
 │    ├── key: (1)
 │    └── fd: (1)-->(2,3)
 └── filters
      └── i:2 IN ($1, $2, $3) [type=bool, outer=(2)]

norm
SELECT * FROM t WHERE i = $1 OR s = $2
----
select
 ├── columns: k:1(int!null) i:2(int) s:3(string)
 ├── has-placeholder
 ├── stats: [rows=3333.333]
 ├── key: (1)
 ├── fd: (1)-->(2,3)
 ├── scan t
 │    ├── columns: k:1(int!null) i:2(int) s:3(string)
 │    ├── stats: [rows=10000, distinct(1)=10000, null(1)=0]
 │    ├── key: (1)
 │    └── fd: (1)-->(2,3)
 └── filters
      └── (i:2 = $1) OR (s:3 = $2) [type=bool, outer=(2,3)]
