This artificial code reproduces bug(?):
drop table test_table; create table test_table (key integer, value integer); drop table test_table_2; create table test_table_2 (key integer, value integer); truncate table test_table; insert into test_table values (1, 1); insert into test_table values (2, 1); insert into test_table values (3, 2); insert into test_table values (4, 2); truncate table test_table_2; insert into test_table_2 values (1, 1); insert into test_table_2 values (2, 2); drop view test_table_view; create view test_table_view as select *, row_number() over () as id from test_table; drop view test_table2_view; create view test_table2_view as select *, row_number() over () as id from test_table_2; select * from ( select t.id as id, t2.id as id2 from test_table_view t join test_table2_view t2 on t.value = t2.value ) where id2 is not null and id2 = 1;