Bug Report
It seems to project twice on temp table.
And I don't think it can handle more complex situations.
explain SELECT b FROM t1 WHERE a in (SELECT a FROM t2 where (select a from t1));
PLAN
-------------------------------------------------------------------
Projection [t1.b] [Project] +
LeftSemi Join On t1.a = (t2.a) as (_temp_table_2_.a) [HashJoin]+
Scan t1 -> [a, b] [SeqScan] +
Projection [(t2.a) as (_temp_table_2_.a)] [Project] +
Projection [t2.a] [Project] +
Inner Join Where _temp_table_1_.a [HashJoin] +
Scan t2 -> [a] [SeqScan] +
Projection [(t2.a) as (_temp_table_1_.a)] [Project] +
Projection [t2.a] [Project] +
Scan t1 -> [] [SeqScan]
I think every query using their own binder context may be a solution, but it may be a big work.
#168 (comment)