|
| 1 | +[ |
| 2 | + { |
| 3 | + "name": "TestOuter2Inner", |
| 4 | + "cases": [ |
| 5 | + "select * from t1 left outer join t2 on a1=a2 where b2 < 1 -- basic case of outer to inner join conversion", |
| 6 | + "select * from t1 left outer join t2 on a1=a2 where b2 is not null -- basic case of not null", |
| 7 | + "select * from t1 left outer join t2 on a1=a2 where not(b2 is null) -- another form of basic case of not null", |
| 8 | + "select * from t1 left outer join t2 on a1=a2 where c2 = 5 OR b2 < 55 -- case with A OR B (Both A and B are null filtering)", |
| 9 | + "select * from t1 left outer join t2 on a1=a2 where c2 = 5 AND b2 is null -- case with A AND B (A is null filtering and B is not)", |
| 10 | + "select * from t1 left outer join t2 on a1=a2 where b2 is NULL AND c2 = 5 -- case with A AND B (A is null filtering and B is not)", |
| 11 | + "select * from t1 left outer join t2 on a1=a2 where not (b2 is NULL OR c2 = 5) -- NOT case ", |
| 12 | + "select * from t1 left outer join t2 on a1=a2 where not (b2 is NULL AND c2 = 5) -- NOT case ", |
| 13 | + "select * from t2 left outer join t1 on a1=a2 where b1+b1 > 2; -- expression evaluates to UNKNOWN/FALSE", |
| 14 | + "select * from t2 left outer join t1 on a1=a2 where coalesce(b1,2) > 2; -- false condition for b1=NULL", |
| 15 | + "select * from t2 left outer join t1 on a1=a2 where true and b1 = 5; -- AND with one branch is null filtering", |
| 16 | + "select * from t2 left outer join t1 on a1=a2 where false OR b1 = 5; -- OR with both branches are null filtering", |
| 17 | + "select * from t3 as t1 left join t3 as t2 on t1.c3 = t2.c3 where t2.b3 != NULL; -- self join", |
| 18 | + "select * from t1 ta left outer join (t1 tb left outer join t1 tc on tb.b1 = tc.b1) on ta.a1=tc.a1; -- nested join. On clause is null filtering on tc.", |
| 19 | + "select * from t1 ta left outer join (t1 tb left outer join t1 tc on tb.b1 = tc.b1) on ta.a1=tc.a1 where tb.a1 > 5; -- nested join. On clause and WHERE clause are filters", |
| 20 | + "select * from (t2 left join t1 on a1=a2) join t3 on b1=b3 -- on clause applied nested join", |
| 21 | + "select * from ((t1 left join t2 on a1=a2) left join t3 on b2=b3) join t4 on b3=b4 -- nested and propagation of null filtering", |
| 22 | + "select * from t1 right join t2 on a1=a2 where exists (select 1 from t3 where b1=b3) -- semi join is null filtering on the outer join", |
| 23 | + "select sum(l_extendedprice) / 7.0 as avg_yearly from lineitem, part where p_partkey = l_partkey and p_brand = 'Brand#44' and p_container = 'WRAP PKG' and l_quantity < ( select 0.2 * avg(l_quantity) from lineitem where l_partkey = p_partkey) -- Q17 in TPCH. null filter on derived outer join", |
| 24 | + "WITH cte AS ( SELECT alias1.col_date AS field1 FROM d AS alias1 LEFT JOIN dd AS alias2 ON alias1.col_blob_key=alias2.col_blob_key WHERE alias1.col_varchar_key IS NULL OR alias1.col_blob_key >= 'a') SELECT * FROM d AS outr1 LEFT OUTER JOIN dd AS outr2 ON (outr1.col_date=outr2.col_date) JOIN cte AS outrcte ON outr2.col_blob_key=outrcte.field1 -- nested complex case", |
| 25 | + "with cte as (select count(a2) as cnt,b2-5 as b3 from t1 left outer join t2 on a1=a2 group by b3) select * from cte where b3 > 1 -- aggregate case.", |
| 26 | + "select * from dd as outr1 WHERE outr1.col_blob IN (SELECT DISTINCT innr1.col_blob_key AS y FROM d AS innrcte left outer join dd AS innr1 ON innr1.pk = innrcte.col_date WHERE outr1.col_int_key > 6)", |
| 27 | + "select * from t0 left outer join t11 on a0=a1 where t0.b0 in (t11.b1, t11.c1) -- each = in the in list is null filtering", |
| 28 | + "select * from t1 left outer join t2 on a1=a2 where b2 is null -- negative case with single predicate which is not null filtering", |
| 29 | + "select * from t1 left outer join t2 on a1=a2 where c2 = 5 OR b2 is null -- negative case with A OR B (A is null filtering and B is not)", |
| 30 | + "select * from t1 left outer join t2 on a1=a2 where not(b2 is not null) -- nested 'not' negative case", |
| 31 | + "select * from t1 left outer join t2 on a1=a2 where not(not(b2 is null)) -- nested 'not' negative case", |
| 32 | + "select * from t1 left outer join t2 on a1=a2 where b1 is not null -- negative case with condition on outer table.", |
| 33 | + "select * from t2 left outer join t1 on a1=a2 where coalesce(b1,2) = 2; -- true condition for b1=NULL", |
| 34 | + "select * from t2 left outer join t1 on a1=a2 where true OR b1 = 5; -- negative case with OR and one branch is TRUE", |
| 35 | + "select * from t3 as t1 left join t3 as t2 on t1.c3 = t2.c3 where t1.b3 != NULL -- negative case with self join", |
| 36 | + "select * from (t1 left outer join t2 on a1=a2) left outer join t3 on a2=a3 and b2 = 5 -- negative case. inner side is not a join", |
| 37 | + "select * from t1 ta right outer join (t1 tb right outer join t1 tc on tb.b1 = tc.b1) on ta.a1=tc.a1; -- negative case. inner side is not a join", |
| 38 | + "select * from t1 ta right outer join (t1 tb right outer join t1 tc on tb.b1 = tc.b1) on ta.a1=tc.a1 where tc.a1 > 5; -- negative case. inner side is not a join and WHERE clause on outer table", |
| 39 | + "select * from (t2 left join t1 on a1=a2) join t3 on b2=b3 -- negative case, on clause on outer table in nested join", |
| 40 | + "select t1.c1 in (select count(s.b1) from t1 s where s.a1 = t1.a1) from t1 -- subquery test that generates outer join and not converted", |
| 41 | + "SELECT * FROM ti LEFT JOIN (SELECT i FROM ti WHERE FALSE) AS d1 ON ti.i = d1.i WHERE NOT EXISTS (SELECT 1 FROM ti AS inner_t1 WHERE i = d1.i) -- anti semi join", |
| 42 | + "select count(*) from t1 where t1.a1+100 > ( select count(*) from t2 where t1.a1=t2.a2 and t1.b1=t2.b2) group by t1.b1 -- filter not filtering over derived outer join", |
| 43 | + "with cte as (select count(a2) as cnt,ifnull(b2,5) as b2 from t1 left outer join t2 on a1=a2 group by b2) select * from cte where b2 > 1 -- non null filter on group by", |
| 44 | + "with cte as (select count(a2) as cnt,ifnull(b2,5) as b2 from t1 left outer join t2 on a1=a2 group by b2) select * from cte where cnt > 1 -- filter on aggregates not applicable", |
| 45 | + "select * from t0 left outer join t11 on a0=a1 where t0.b0 in (t0.b0, t11.b1)", |
| 46 | + "select * from t0 left outer join t11 on a0=a1 where '5' not in (t0.b0, t11.b1)", |
| 47 | + "select * from t0 left outer join t11 on a0=a1 where '1' in (t0.b0, t11.b1)", |
| 48 | + "select * from t0 left outer join t11 on a0=a1 where t0.b0 in ('5', t11.b1) -- some = in the in list is not null filtering", |
| 49 | + "select * from t0 left outer join t11 on a0=a1 where '5' in (t0.b0, t11.b1) -- some = in the in list is not null filtering", |
| 50 | + "select * from t1 left outer join t2 on a1=a2 where not (b2 is NOT NULL AND c2 = 5) -- NOT case " |
| 51 | + ] |
| 52 | + } |
| 53 | +] |
0 commit comments