zhouqingqing / qpmodel

A Relational Optimizer and Executor
MIT License
64 stars 18 forks source link

REMOVE_FROM WORK: stage 1 #245

Closed pkommoju closed 3 years ago

pkommoju commented 3 years ago

remove_from set to true is causing some issues. The first is the invalid grouping column reference error. This fix remembers the last expression poistion required from the child before grouping expression are added and raises error only if the offending expression occurs before this position.

Also, remove_from=true in most cases requires naming the columns of the FromQuery results (derived columns).

The following queries are disabled in this PR, they will be fixed in a later one.

1) SELECT e1 FROM (SELECT d1 FROM (SELECT Sum(ab12) FROM (SELECT e1 b2 ab12 FROM (SELECT e1 FROM (SELECT d1 FROM (SELECT Sum(ab12) FROM (SELECT a1 b2 ab12 FROM a JOIN b ON a1 = b1) b) c(d1)) d(e1)) a JOIN b ON e1 = 8b1) b) c(d1)) d(e1); 2) select b1+c100 from (select count() as b1 from b) a, (select c1 c100 from c) c where c100>1

3) select a.b1+c.b1 from (select count(*) as b1 from b) a, (select c1 b1 from c) c where c.b1>1;

4) select count(c1), sum(c2) from (select from a union all select from b) c(c1,c2)

5) select from (select from a union all select * from b) c(c1,c2) order by 1"

6) select a1 from c,a, b where a1=b1 and b2=c2 and a.a1 = (select b1 from(select b_2.b1, b_1.b2, b_1.b3 from b b_1, b b_2) bo where b2 = a2 and b1 = (select b1 from b where b3 = a3 and bo.b3 = c3 and b3> 1) and b2<5) and a.a2 = (select b2 from b bo where b1 = a1 and b2 = (select b2 from b where b4 = a3 + 1 and bo.b3 = a3 and b3> 0) and c3<5);

7) tpcds is allowed to run and fail.