Issue found by SQLSmith on git commit hash dd9e6 using seed 340556115.
To Reproduce
call dbgen(sf=0.1);
SELECT NULL FROM (SELECT ref_2.c_custkey AS c0, ref_2.c_acctbal AS c1, argmin(CAST(CAST(NULL AS TIMESTAMP) AS TIMESTAMP), CAST(CAST(NULL AS TIMESTAMP) AS TIMESTAMP)) OVER (PARTITION BY ref_2.c_phone ORDER BY ref_0.s_nationkey) AS c2, (SELECT c_comment FROM main.customer LIMIT 1 OFFSET 5) AS c3, ref_1.ps_suppkey AS c4, ref_2.c_address AS c5, ref_1.ps_comment AS c6, ref_0.s_acctbal AS c7, 97 AS c8, ref_1.ps_supplycost AS c9, ref_2.c_acctbal AS c10, ref_0.s_address AS c11 FROM main.supplier AS ref_0 RIGHT JOIN main.partsupp AS ref_1 ON ((ref_0.s_phone = ref_1.ps_comment)) RIGHT JOIN main.customer AS ref_2 ON (((ref_0.s_comment ~~~ ref_2.c_mktsegment) OR (ref_1.ps_availqty IS NOT NULL))) WHERE (1 AND (ref_2.c_mktsegment ~~ ref_0.s_name)) LIMIT 28) INNER JOIN (SELECT ref_3.o_clerk AS c0, ref_3.o_clerk AS c1, ref_3.o_orderkey AS c2, ref_3.o_totalprice AS c3 FROM main.orders AS ref_3 WHERE ((ref_3.o_orderpriority !~~* CAST(NULL AS VARCHAR)) AND EXISTS(SELECT ref_3.o_custkey AS c0, ref_3.o_orderdate AS c1, ref_3.o_comment AS c2, ref_3.o_orderkey AS c3 FROM main.supplier AS ref_4 WHERE (ref_4.s_acctbal IS NOT NULL) LIMIT 49)) LIMIT 131) AS subq_1 INNER JOIN main.region AS ref_5 INNER JOIN main.supplier AS ref_6 ON ((ref_5.r_name !~~ ref_5.r_comment)) INNER JOIN main.partsupp AS ref_7 LEFT JOIN main.lineitem AS ref_8 INNER JOIN main.nation AS ref_9 ON ((ref_8.l_comment ~~ ref_9.n_comment)) ON ((((SELECT c_name FROM main.customer LIMIT 1 OFFSET 1) ~~ ref_9.n_name) OR (ref_9.n_comment ~~* ref_8.l_returnflag))) ON ((ref_6.s_comment !~~ ref_8.l_shipinstruct)) ON ((ref_9.n_comment ^@ ref_6.s_address)) ON (EXISTS(SELECT ref_9.n_name AS c0, ref_12.r_name AS c1, subq_1.c1 AS c2, ref_8.l_discount AS c3 FROM main.partsupp AS ref_10 INNER JOIN main.partsupp AS ref_11 INNER JOIN main.region AS ref_12 ON ((ref_11.ps_comment = ref_12.r_name)) ON ((ref_12.r_name IS NOT NULL)) WHERE (ref_8.l_linestatus ~~~ CAST(NULL AS VARCHAR))))
Error Message
ABORT THROWN BY INTERNAL EXCEPTION: Failed to bind column reference "c0" [34.1] (bindings: {#[17.0], #[17.1], #[17.2], #[17.3]})
Issue found by SQLSmith on git commit hash dd9e6 using seed 340556115.
To Reproduce
Error Message