# -------------------------------------------------------------- # # Test case migrated from Autopilot outer join test suite # # Author: Daniel Lee, daniel.lee@mariadb.com # -------------------------------------------------------------- # # --source ../include/have_columnstore.inc # USE outerjoin; # # conventional, conventional, conventional select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join customer c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey where c_custkey < 10 order by 1, 2, 3, 4, 5, 6; # conventional, conventional, conventional, with filter in subquery select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # conventional, conventional, left select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey left join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # conventional, conventional, right select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey right join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # conventional, left, conventional select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey left join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # conventional, left, left select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey left join nation n on c.c_nationkey = n.n_nationkey left join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # conventional, left, right select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey left join nation n on c.c_nationkey = n.n_nationkey right join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # conventional, right, conventional select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey right join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # conventional, right, left select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey right join nation n on c.c_nationkey = n.n_nationkey left join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # conventional, right, right select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey right join nation n on c.c_nationkey = n.n_nationkey right join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # left, conventional, conventional select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # left, conventional, left select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey left join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # left, conventional, right select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey right join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # left, left, conventional select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey left join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # left, left, left select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey left join nation n on c.c_nationkey = n.n_nationkey left join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # left, left, right select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey left join nation n on c.c_nationkey = n.n_nationkey right join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # left, right, conventional select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey right join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # left, right, left select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey right join nation n on c.c_nationkey = n.n_nationkey left join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # left, right, right select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey right join nation n on c.c_nationkey = n.n_nationkey right join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # left, conventional, conventional select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # left, conventional, left select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey left join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # left, conventional, right select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o left join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey join nation n on c.c_nationkey = n.n_nationkey right join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # right, left, conventional select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o right join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey left join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # right, left, left select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o right join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey left join nation n on c.c_nationkey = n.n_nationkey left join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # right, left, right select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o right join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey left join nation n on c.c_nationkey = n.n_nationkey right join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # # right, right, conventional select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o right join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey right join nation n on c.c_nationkey = n.n_nationkey join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # right, right, left select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o right join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey right join nation n on c.c_nationkey = n.n_nationkey left join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # right, right, right select o.o_custkey, c.c_custkey,c.c_nationkey,n.n_nationkey,n.n_regionkey, r.r_regionkey from orders o right join (select * from customer where c_custkey < 10) c on o.o_custkey = c.c_custkey right join nation n on c.c_nationkey = n.n_nationkey right join region r on n.n_regionkey = r.r_regionkey order by 1, 2, 3, 4, 5, 6; # select * from t1 join t2 on t1.c=t2.c join t3 on t2.c=t3.c join t4 on t1.c=t4.c order by 4; # select * from t1 join t2 on t1.c=t2.c join t3 on t2.c=t3.c left join t4 on t1.c=t4.c order by 4; # select * from t1 join t2 on t1.c=t2.c join t3 on t2.c=t3.c right join t4 on t1.c=t4.c order by 4; # select * from t1 join t2 on t1.c=t2.c left join t3 on t2.c=t3.c join t4 on t1.c=t4.c order by 4; # select * from t1 join t2 on t1.c=t2.c left join t3 on t2.c=t3.c left join t4 on t1.c=t4.c order by 4; # select * from t1 join t2 on t1.c=t2.c left join t3 on t2.c=t3.c right join t4 on t1.c=t4.c order by 4; # select * from t1 join t2 on t1.c=t2.c right join t3 on t2.c=t3.c join t4 on t1.c=t4.c order by 4; # select * from t1 join t2 on t1.c=t2.c right join t3 on t2.c=t3.c left join t4 on t1.c=t4.c order by 4; # select * from t1 join t2 on t1.c=t2.c right join t3 on t2.c=t3.c right join t4 on t1.c=t4.c order by 4; # select * from t1 left join t2 on t1.c=t2.c join t3 on t2.c=t3.c join t4 on t1.c=t4.c order by 4; # select * from t1 left join t2 on t1.c=t2.c join t3 on t2.c=t3.c left join t4 on t1.c=t4.c order by 4; # select * from t1 left join t2 on t1.c=t2.c join t3 on t2.c=t3.c right join t4 on t1.c=t4.c order by 4; # select * from t1 left join t2 on t1.c=t2.c left join t3 on t2.c=t3.c join t4 on t1.c=t4.c order by 4; # select * from t1 left join t2 on t1.c=t2.c left join t3 on t2.c=t3.c left join t4 on t1.c=t4.c order by 4; # select * from t1 left join t2 on t1.c=t2.c left join t3 on t2.c=t3.c right join t4 on t1.c=t4.c order by 4; # select * from t1 left join t2 on t1.c=t2.c right join t3 on t2.c=t3.c join t4 on t1.c=t4.c order by 4; # select * from t1 left join t2 on t1.c=t2.c right join t3 on t2.c=t3.c left join t4 on t1.c=t4.c order by 4; # select * from t1 left join t2 on t1.c=t2.c right join t3 on t2.c=t3.c right join t4 on t1.c=t4.c order by 4; # select * from t1 right join t2 on t1.c=t2.c join t3 on t2.c=t3.c join t4 on t1.c=t4.c order by 4; # select * from t1 right join t2 on t1.c=t2.c join t3 on t2.c=t3.c left join t4 on t1.c=t4.c order by 4; # select * from t1 right join t2 on t1.c=t2.c join t3 on t2.c=t3.c right join t4 on t1.c=t4.c order by 4; # select * from t1 right join t2 on t1.c=t2.c left join t3 on t2.c=t3.c join t4 on t1.c=t4.c order by 4; # select * from t1 right join t2 on t1.c=t2.c left join t3 on t2.c=t3.c left join t4 on t1.c=t4.c order by 4; # select * from t1 right join t2 on t1.c=t2.c left join t3 on t2.c=t3.c right join t4 on t1.c=t4.c order by 4; # select * from t1 right join t2 on t1.c=t2.c right join t3 on t2.c=t3.c join t4 on t1.c=t4.c order by 4; # select * from t1 right join t2 on t1.c=t2.c right join t3 on t2.c=t3.c left join t4 on t1.c=t4.c order by 4; # select * from t1 right join t2 on t1.c=t2.c right join t3 on t2.c=t3.c right join t4 on t1.c=t4.c order by 4; #