exec-ddl
CREATE TABLE a (
  x INT PRIMARY KEY,
  y INT,
  s STRING,
  d DECIMAL NOT NULL,
  UNIQUE (s DESC, d),
  UNIQUE (y, s)
)
----

exec-ddl
CREATE TABLE abc (
  a INT,
  b INT,
  c INT,
  d INT,
  PRIMARY KEY (a, b),
  INDEX (c)
)
----

# In order to actually create new logical props for the index join, we need to
# call ConstructLookupJoin, which only happens when where is a remaining filter.
opt
SELECT * FROM a WHERE s = 'foo' AND x + y = 10
----
select
 ├── columns: x:1(int!null) y:2(int) s:3(string!null) d:4(decimal!null)
 ├── immutable
 ├── key: (1)
 ├── fd: ()-->(3), (1)-->(2,4), (4)-->(1,2), (2,3)~~>(1,4)
 ├── prune: (4)
 ├── interesting orderings: (+1 opt(3)) (+4 opt(3)) (+2,+1 opt(3))
 ├── index-join a
 │    ├── columns: x:1(int!null) y:2(int) s:3(string) d:4(decimal!null)
 │    ├── key: (1)
 │    ├── fd: ()-->(3), (1)-->(2,4), (4)-->(1), (3,4)~~>(1,2), (2,3)~~>(1,4)
 │    ├── interesting orderings: (+4 opt(3))
 │    └── scan a@a_s_d_key
 │         ├── columns: x:1(int!null) s:3(string!null) d:4(decimal!null)
 │         ├── constraint: /-3/4: [/'foo' - /'foo']
 │         ├── key: (1)
 │         ├── fd: ()-->(3), (1)-->(4), (4)-->(1)
 │         ├── prune: (1,3,4)
 │         └── interesting orderings: (+4 opt(3))
 └── filters
      └── eq [type=bool, outer=(1,2), immutable]
           ├── plus [type=int]
           │    ├── variable: x:1 [type=int]
           │    └── variable: y:2 [type=int]
           └── const: 10 [type=int]

opt
SELECT y FROM a WHERE s = 'foo' AND x + y = 10
----
project
 ├── columns: y:2(int)
 ├── immutable
 ├── prune: (2)
 ├── interesting orderings: (+2)
 └── select
      ├── columns: x:1(int!null) y:2(int) s:3(string!null)
      ├── immutable
      ├── key: (1)
      ├── fd: ()-->(3), (1)-->(2), (2,3)~~>(1)
      ├── interesting orderings: (+1 opt(3)) (+2,+1 opt(3))
      ├── index-join a
      │    ├── columns: x:1(int!null) y:2(int) s:3(string)
      │    ├── key: (1)
      │    ├── fd: ()-->(3), (1)-->(2), (2,3)~~>(1)
      │    └── scan a@a_s_d_key
      │         ├── columns: x:1(int!null) s:3(string!null)
      │         ├── constraint: /-3/4: [/'foo' - /'foo']
      │         ├── key: (1)
      │         ├── fd: ()-->(3)
      │         └── prune: (1,3)
      └── filters
           └── eq [type=bool, outer=(1,2), immutable]
                ├── plus [type=int]
                │    ├── variable: x:1 [type=int]
                │    └── variable: y:2 [type=int]
                └── const: 10 [type=int]

# Use secondary index to join to multi-valued primary index, but project only
# a subset of the primary columns.
opt
SELECT b, c, d FROM abc WHERE c=1 AND d=2
----
select
 ├── columns: b:2(int!null) c:3(int!null) d:4(int!null)
 ├── fd: ()-->(3,4)
 ├── prune: (2)
 ├── index-join abc
 │    ├── columns: b:2(int!null) c:3(int) d:4(int)
 │    ├── fd: ()-->(3)
 │    ├── interesting orderings: (+1,+2 opt(3))
 │    └── scan abc@abc_c_idx
 │         ├── columns: a:1(int!null) b:2(int!null) c:3(int!null)
 │         ├── constraint: /3/1/2: [/1 - /1]
 │         ├── key: (1,2)
 │         ├── fd: ()-->(3)
 │         ├── prune: (1-3)
 │         └── interesting orderings: (+1,+2 opt(3))
 └── filters
      └── eq [type=bool, outer=(4), constraints=(/4: [/2 - /2]; tight), fd=()-->(4)]
           ├── variable: d:4 [type=int]
           └── const: 2 [type=int]
