Issue found by SQLSmith on git commit hash 950d7 using seed 1050562084.
To Reproduce
create table all_types as select * exclude(small_enum, medium_enum, large_enum) from test_all_types();
WITH jennifer_0 AS (SELECT ref_0."struct" AS c0, CASE WHEN ((EXISTS(SELECT subq_0.c0 AS c0, ref_1."timestamp" AS c1, 57 AS c2, ref_0."timestamp" AS c3 FROM main.all_types AS ref_1 , (SELECT ref_2."union" AS c0, ref_2.fixed_array_of_int_list AS c1 FROM main.all_types AS ref_2 WHERE (ref_2.uuid IS NULL)) AS subq_0 WHERE EXISTS(SELECT ref_0.utinyint AS c0 FROM main.all_types AS ref_3 , (SELECT ref_3.uint AS c0, ref_4."interval" AS c1, ref_4.nested_int_array AS c2 FROM main.all_types AS ref_4 , (SELECT ref_4.dec_18_6 AS c0, ref_5.date AS c1, ref_1.fixed_nested_int_array AS c2, ref_4.usmallint AS c3, ref_3.date_array AS c4 FROM main.all_types AS ref_5 WHERE EXISTS(SELECT (SELECT "double" FROM main.all_types LIMIT 1 OFFSET 51) AS c0, ref_6.fixed_array_of_int_list AS c1 FROM main.all_types AS ref_6 WHERE 1 LIMIT 91) LIMIT 140) AS subq_1 WHERE (ref_4."varchar" ~~* ref_4."varchar")) AS subq_2 WHERE 0) LIMIT 70) OR (ref_0."varchar" ~~ ref_0."varchar"))) THEN (CASE WHEN ((ref_0."varchar" !~~* (SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 98))) THEN ((SELECT fixed_struct_array FROM main.all_types LIMIT 1 OFFSET 6)) ELSE (SELECT fixed_struct_array FROM main.all_types LIMIT 1 OFFSET 6) END) ELSE CASE WHEN ((SELECT NULL LIMIT 1 OFFSET 98)) THEN ((SELECT NULL)) ELSE (SELECT NULL) END END AS c1, ref_0.uint AS c3 FROM main.all_types AS ref_0 WHERE (ref_0."varchar" ~~* ref_0."varchar"))SELECT subq_4.c3 AS c0 FROM jennifer_0 AS ref_7 , (SELECT CASE WHEN (((SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 3) ~~~ (SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 6))) THEN (ref_7.c0) ELSE ref_7.c0 END AS c0, ref_7.c3 AS c1, subq_3.c9 AS c2, subq_3.c7 AS c3 FROM (SELECT ref_8.usmallint AS c0, ref_8.uuid AS c1, ref_8.blob AS c2, ref_8."smallint" AS c3, ref_7.c3 AS c4, ref_8.fixed_struct_array AS c5, ref_7.c3 AS c6, ref_7.c0 AS c7, ref_7.c3 AS c8, ref_7.c0 AS c9, ref_8.dec38_10 AS c10 FROM main.all_types AS ref_8 WHERE (ref_8."varchar" ~~* ref_8."varchar") LIMIT 81) AS subq_3 WHERE ((CAST(NULL AS VARCHAR) !~~* CAST(NULL AS VARCHAR)) OR 0)) AS subq_4 WHERE (CASE WHEN ((((SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 41) ~~* CAST(NULL AS VARCHAR)) AND 0)) THEN (json_type(CAST(CAST("nullif"(CASE WHEN ((41 IS NOT NULL)) THEN ((SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 6)) ELSE (SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 6) END, CAST(NULL AS VARCHAR)) AS VARCHAR) AS VARCHAR), CAST((SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 6) AS VARCHAR))) ELSE json_type(CAST(CAST("nullif"(CASE WHEN ((41 IS NOT NULL)) THEN ((SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 6)) ELSE (SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 6) END, CAST(NULL AS VARCHAR)) AS VARCHAR) AS VARCHAR), CAST((SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 6) AS VARCHAR)) END !~~ CAST("nullif"(current_schema(), CAST(COALESCE(json_pretty(CAST(CAST(NULL AS "json") AS "json")), CAST(COALESCE((SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 5), current_schema()) AS VARCHAR)) AS VARCHAR)) AS VARCHAR))
Error Message
ABORT THROWN BY INTERNAL EXCEPTION: Failed to bind column reference "c2" [50.1] (bindings: {#[9.0], #[9.1], #[234.0], #[234.1]})
Issue found by SQLSmith on git commit hash 950d7 using seed 1050562084.
To Reproduce
Error Message