Fix lateral PANIC issue when subquery contain limit or groupby.
Previous commit 62579728 fixes a lateral panic issue but does not handle all the bad cases because it only check if the query tree contains limit clause. Bad cases for example: if the subquery is like `q1 union all (q2 limit 1)` then the whole query tree does not contain limit clause. Another bad case is the lateral subquery may contain groupby. like: select * from t1_lateral_limit t1 cross join lateral (select (c).x+t2.a, sum(t2.a+t2.b) from t2_lateral_limit t2 group by (c).x+t2.a)x; When planning the lateraled subquery we do not know where is the param in the subquery's query tree. Thus it is a bit complicated to precisely and efficiently resolve this issue. This commit adopts a simple method to fix panic issue: it justs check the subquery's query tree to see if there is any group-by or limit clause, if so, force gather each relation and materialize them. This is not the best plan we might get. But let's make it correct first and I think in future we should seriously consider how to fully and efficiently support lateral.
Showing
想要评论请 注册 或 登录