# This is a comment.
lookup-constraints left=(a int) right=(x int) index=(x)
x = a
----
key cols:
  x = a

lookup-constraints left=(a int) right=(x int, y int) index=(x)
x = a AND (y > 10 OR y IN (1, 5))
----
key cols:
  x = a
remaining filters:
  (y > 10) OR (y IN (1, 5))

lookup-constraints left=(a int) right=(x int, y int) index=(x)
x = 1
----
lookup join not possible

lookup-constraints left=(a int) right=(x int, y int) index=(x)
y = a
----
lookup join not possible

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
x = a
----
key cols:
  x = a

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
x = a AND y = b
----
key cols:
  x = a
  y = b

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
x = a AND z = b
----
key cols:
  x = a
remaining filters:
  z = b

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
x = a
optional: z = 1
----
key cols:
  x = a

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
x = a AND y = b AND z = c
----
key cols:
  x = a
  y = b
  z = c

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y)
x = a AND y = b AND z = c
----
key cols:
  x = a
  y = b
remaining filters:
  z = c

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y)
x = a AND y = b AND z > 20
----
key cols:
  x = a
  y = b
remaining filters:
  z > 20

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y)
x = a
optional: y = 1 AND z > 20
----
key cols:
  x = a
  y = lookup_join_const_col_@8
input projections:
  lookup_join_const_col_@8 = 1 [type=INT8]

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
y = b AND z = c
----
lookup join not possible

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
x = 1 AND y = b
----
key cols:
  x = lookup_join_const_col_@7
  y = b
input projections:
  lookup_join_const_col_@7 = 1 [type=INT8]

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
x = 1 AND y = 2 AND z = c
----
key cols:
  x = lookup_join_const_col_@7
  y = lookup_join_const_col_@8
  z = c
input projections:
  lookup_join_const_col_@7 = 1 [type=INT8]
  lookup_join_const_col_@8 = 2 [type=INT8]

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
x = 1 AND y = b AND z = 3
----
key cols:
  x = lookup_join_const_col_@7
  y = b
  z = lookup_join_const_col_@9
input projections:
  lookup_join_const_col_@7 = 1 [type=INT8]
  lookup_join_const_col_@9 = 3 [type=INT8]

lookup-constraints left=(a int, b int, c int, d int) right=(x int, y int, z int) index=(x, y, z)
d > 4 AND x = 1 AND y = b AND z = 3
----
key cols:
  x = lookup_join_const_col_@8
  y = b
  z = lookup_join_const_col_@10
input projections:
  lookup_join_const_col_@8 = 1 [type=INT8]
  lookup_join_const_col_@10 = 3 [type=INT8]
remaining filters:
  d > 4

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y)
x = 1 AND y = b AND z = 3
----
key cols:
  x = lookup_join_const_col_@7
  y = b
input projections:
  lookup_join_const_col_@7 = 1 [type=INT8]
remaining filters:
  z = 3

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y)
y = b
optional: x = 1 AND z = 3
----
key cols:
  x = lookup_join_const_col_@7
  y = b
input projections:
  lookup_join_const_col_@7 = 1 [type=INT8]

lookup-constraints left=(a int) right=(x int, y int, z int) index=(x, z)
a = z AND (x = 0 OR y IN (0) AND y > 0)
----
key cols:
  x = lookup_join_const_col_@5
  z = a
input projections:
  lookup_join_const_col_@5 = 0 [type=INT8]

lookup-constraints left=(a int, b int) right=(x int, y int, z int) index=(x, y, z)
x = a AND y = b
optional: z IN (3, 4)
----
key cols:
  x = a
  y = b

lookup-constraints left=(a int, b int) right=(x int, y int, z int) index=(x, y, z)
x = 1 AND y = b
optional: z IN (3, 4)
----
key cols:
  x = lookup_join_const_col_@6
  y = b
input projections:
  lookup_join_const_col_@6 = 1 [type=INT8]

lookup-constraints left=(a int, b int, c int) right=(x int, y int, z int) index=(x, y, z)
x = a
optional: z IN (3, 4) AND y IN (10, 20)
----
key cols:
  x = a

lookup-constraints left=(a int, b int) right=(x int, y int, z int) index=(x, y, z)
x = a AND y = b
optional: z > 10
----
key cols:
  x = a
  y = b

lookup-constraints left=(a int, b int) right=(x int, y int, z int) index=(x, y, z)
x = 1 AND y = b
optional: z > 10
----
key cols:
  x = lookup_join_const_col_@6
  y = b
input projections:
  lookup_join_const_col_@6 = 1 [type=INT8]

lookup-constraints left=(a int, b int) right=(x int, y int, z int, zz int) index=(x, y, z, zz)
x = 1 AND y = b
optional: z > 10 AND zz > 0
----
key cols:
  x = lookup_join_const_col_@6
  y = b
input projections:
  lookup_join_const_col_@6 = 1 [type=INT8]

# The projected constant should not have type modifiers of the indexed column.
lookup-constraints left=(a int) right=(x int, y CHAR(2)) index=(x, y)
x = a AND y = 'foo'
----
key cols:
  x = a
  y = lookup_join_const_col_@6
input projections:
  lookup_join_const_col_@6 = 'foo' [type=STRING]

lookup-constraints left=(a int) right=(x int, y VARCHAR(2)) index=(x, y)
x = a AND y = 'foo'
----
key cols:
  x = a
  y = lookup_join_const_col_@6
input projections:
  lookup_join_const_col_@6 = 'foo' [type=STRING]

lookup-constraints left=(a int) right=(x int, y BIT(2)) index=(x, y)
x = a AND y = '111'
----
key cols:
  x = a
  y = lookup_join_const_col_@6
input projections:
  lookup_join_const_col_@6 = B'111' [type=VARBIT]

lookup-constraints left=(a int) right=(x int, y VARBIT(2)) index=(x, y)
x = a AND y = '111'
----
key cols:
  x = a
  y = lookup_join_const_col_@6
input projections:
  lookup_join_const_col_@6 = B'111' [type=VARBIT]

lookup-constraints left=(a int) right=(x int, y DECIMAL(6,2)) index=(x, y)
x = a AND y = 1234.1234::DECIMAL(8, 4)
----
key cols:
  x = a
  y = lookup_join_const_col_@6
input projections:
  lookup_join_const_col_@6 = 1234.1234 [type=DECIMAL]
