When I removed "window w0 as (partition by ref_33.c_3 order by
ref_33.c_4 desc)" in the test case query, the query did not trigger
errors any more.
Specifically, this query did not trigger errors:
with cte_1 as (select
ref_1.c_0 as c_2,
ref_1.c_4 as c_3,
case when (nullif(ref_1.c_2, ref_1.c_0) <> (
select
ref_53.c_2 as c_0
from
(t1 as ref_52 left outer join t3 as ref_53 on true)
where (ref_53.c_6) ~~ (ref_53.c_6)
order by c_0 limit 1)
) then null else null end
as c_4
from
t3 as ref_1)
select 1
from
cte_1 as ref_33
where (ref_33.c_2 > (
select
ref_200.c_2 as c_0
from
t3 as ref_200
order by c_0 limit 1));