Files
impala/testdata/workloads/functional-query/queries/QueryTest/outer-joins.test
Alex Behm a85dacafe8 IMPALA-904: Make TupleIsNullPredicate work on non-nullable tuples.
We wrap certain exprs substituted from outer-joined inline view in an expr that
evaluates to NULL if the underling tuple(s) are NULL. We do this for exprs that evaluate
to non-NULL values if their slots are NULL, i.e., we must then distinguish tuples that are
NULL from slots that are NULL (otherwise evaluating an expr against a tuple that is NULL
due to the outer join may incorrectly return a non-NULL value.)

The bug: Exprs referring to an outer-joined inline view may appear in various places
in the outer query block. For example, they could appear in an On-clause or be
placed into scans/aggregates due to predicate propagation. In such cases, the underlying
tuples may not be nullable yet because they only become nullable after the outer join.
We had a DCHECK in tuple-is-null-predicate.cc requiring the tuples to be nullable.
The fix: Remove the DCHECK. The fix is not elegant but practical. It would be rather
difficult to fix the inline view expr substitution such that a TupleIsNullPredicate
never references a non-nullable tuple, esp. due to predicate propagation.

Change-Id: I180f75f14173f356abfeec751e6b2d419378a9a7
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2157
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
2014-04-07 14:18:49 -07:00

631 lines
20 KiB
Plaintext

====
---- QUERY
# join cols aren't part of select list (and still get materialized)
select j.test_name, d.name
from JoinTbl j inner join DimTbl d on (j.test_id = d.id)
---- TYPES
string, string
---- RESULTS
'Name1','Name1'
'Name16','Name6'
'Name16','Name6'
'Name16','Name6'
'Name16','Name6'
'Name2','Name2'
'Name3','Name3'
'Name4','Name4'
'Name5','Name5'
'Name6','Name6'
'Name6','Name6'
====
---- QUERY
# join on bigint
select j.*, d.*
from JoinTbl j inner join DimTbl d on (j.test_id = d.id)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1003,'Name3',94612
1004,'Name4',94611,5000,1004,'Name4',94612
1005,'Name5',94611,5000,1005,'Name5',94613
1006,'Name16',94612,15000,1006,'Name6',94613
1006,'Name16',94612,5000,1006,'Name6',94613
1006,'Name16',94616,15000,1006,'Name6',94613
1006,'Name16',94616,5000,1006,'Name6',94613
1006,'Name6',94616,15000,1006,'Name6',94613
1006,'Name6',94616,5000,1006,'Name6',94613
====
---- QUERY
select j.*, d.*
from JoinTbl j left outer join DimTbl d on (j.test_id = d.id)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1003,'Name3',94612
1004,'Name4',94611,5000,1004,'Name4',94612
1005,'Name5',94611,5000,1005,'Name5',94613
1006,'Name16',94612,15000,1006,'Name6',94613
1006,'Name16',94612,5000,1006,'Name6',94613
1006,'Name16',94616,15000,1006,'Name6',94613
1006,'Name16',94616,5000,1006,'Name6',94613
1006,'Name6',94616,15000,1006,'Name6',94613
1006,'Name6',94616,5000,1006,'Name6',94613
1106,'Name16',94612,15000,NULL,'NULL',NULL
1106,'Name16',94612,5000,NULL,'NULL',NULL
1106,'Name16',94616,15000,NULL,'NULL',NULL
1106,'Name16',94616,5000,NULL,'NULL',NULL
1106,'Name6',94612,15000,NULL,'NULL',NULL
1106,'Name6',94612,5000,NULL,'NULL',NULL
1106,'Name6',94616,15000,NULL,'NULL',NULL
1106,'Name6',94616,5000,NULL,'NULL',NULL
====
---- QUERY
select j.*, d.*
from JoinTbl j right outer join DimTbl d on (j.test_id = d.id)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1003,'Name3',94612
1004,'Name4',94611,5000,1004,'Name4',94612
1005,'Name5',94611,5000,1005,'Name5',94613
1006,'Name16',94612,15000,1006,'Name6',94613
1006,'Name16',94612,5000,1006,'Name6',94613
1006,'Name16',94616,15000,1006,'Name6',94613
1006,'Name16',94616,5000,1006,'Name6',94613
1006,'Name6',94616,15000,1006,'Name6',94613
1006,'Name6',94616,5000,1006,'Name6',94613
NULL,'NULL',NULL,NULL,1007,'Name7',94614
NULL,'NULL',NULL,NULL,1008,'Name8',94614
NULL,'NULL',NULL,NULL,1009,'Name9',94615
NULL,'NULL',NULL,NULL,1010,'Name10',94615
====
---- QUERY
select j.*, d.*
from JoinTbl j full outer join DimTbl d on (j.test_id = d.id)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1003,'Name3',94612
1004,'Name4',94611,5000,1004,'Name4',94612
1005,'Name5',94611,5000,1005,'Name5',94613
1006,'Name16',94612,15000,1006,'Name6',94613
1006,'Name16',94612,5000,1006,'Name6',94613
1006,'Name16',94616,15000,1006,'Name6',94613
1006,'Name16',94616,5000,1006,'Name6',94613
1006,'Name6',94616,15000,1006,'Name6',94613
1006,'Name6',94616,5000,1006,'Name6',94613
1106,'Name16',94612,15000,NULL,'NULL',NULL
1106,'Name16',94612,5000,NULL,'NULL',NULL
1106,'Name16',94616,15000,NULL,'NULL',NULL
1106,'Name16',94616,5000,NULL,'NULL',NULL
1106,'Name6',94612,15000,NULL,'NULL',NULL
1106,'Name6',94612,5000,NULL,'NULL',NULL
1106,'Name6',94616,15000,NULL,'NULL',NULL
1106,'Name6',94616,5000,NULL,'NULL',NULL
NULL,'NULL',NULL,NULL,1007,'Name7',94614
NULL,'NULL',NULL,NULL,1008,'Name8',94614
NULL,'NULL',NULL,NULL,1009,'Name9',94615
NULL,'NULL',NULL,NULL,1010,'Name10',94615
====
---- QUERY
# join on string
select j.*, d.*
from JoinTbl j inner join DimTbl d on (j.test_name = d.name)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1003,'Name3',94612
1004,'Name4',94611,5000,1004,'Name4',94612
1005,'Name5',94611,5000,1005,'Name5',94613
1006,'Name6',94616,15000,1006,'Name6',94613
1006,'Name6',94616,5000,1006,'Name6',94613
1106,'Name6',94612,15000,1006,'Name6',94613
1106,'Name6',94612,5000,1006,'Name6',94613
1106,'Name6',94616,15000,1006,'Name6',94613
1106,'Name6',94616,5000,1006,'Name6',94613
====
---- QUERY
select j.*, d.*
from JoinTbl j left outer join DimTbl d on (j.test_name = d.name)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1003,'Name3',94612
1004,'Name4',94611,5000,1004,'Name4',94612
1005,'Name5',94611,5000,1005,'Name5',94613
1006,'Name16',94612,15000,NULL,'NULL',NULL
1006,'Name16',94612,5000,NULL,'NULL',NULL
1006,'Name16',94616,15000,NULL,'NULL',NULL
1006,'Name16',94616,5000,NULL,'NULL',NULL
1006,'Name6',94616,15000,1006,'Name6',94613
1006,'Name6',94616,5000,1006,'Name6',94613
1106,'Name16',94612,15000,NULL,'NULL',NULL
1106,'Name16',94612,5000,NULL,'NULL',NULL
1106,'Name16',94616,15000,NULL,'NULL',NULL
1106,'Name16',94616,5000,NULL,'NULL',NULL
1106,'Name6',94612,15000,1006,'Name6',94613
1106,'Name6',94612,5000,1006,'Name6',94613
1106,'Name6',94616,15000,1006,'Name6',94613
1106,'Name6',94616,5000,1006,'Name6',94613
====
---- QUERY
select j.*, d.*
from JoinTbl j right outer join DimTbl d on (j.test_name = d.name)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1003,'Name3',94612
1004,'Name4',94611,5000,1004,'Name4',94612
1005,'Name5',94611,5000,1005,'Name5',94613
1006,'Name6',94616,15000,1006,'Name6',94613
1006,'Name6',94616,5000,1006,'Name6',94613
1106,'Name6',94612,15000,1006,'Name6',94613
1106,'Name6',94612,5000,1006,'Name6',94613
1106,'Name6',94616,15000,1006,'Name6',94613
1106,'Name6',94616,5000,1006,'Name6',94613
NULL,'NULL',NULL,NULL,1007,'Name7',94614
NULL,'NULL',NULL,NULL,1008,'Name8',94614
NULL,'NULL',NULL,NULL,1009,'Name9',94615
NULL,'NULL',NULL,NULL,1010,'Name10',94615
====
---- QUERY
select j.*, d.*
from JoinTbl j full outer join DimTbl d on (j.test_name = d.name)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1003,'Name3',94612
1004,'Name4',94611,5000,1004,'Name4',94612
1005,'Name5',94611,5000,1005,'Name5',94613
1006,'Name16',94612,15000,NULL,'NULL',NULL
1006,'Name16',94612,5000,NULL,'NULL',NULL
1006,'Name16',94616,15000,NULL,'NULL',NULL
1006,'Name16',94616,5000,NULL,'NULL',NULL
1006,'Name6',94616,15000,1006,'Name6',94613
1006,'Name6',94616,5000,1006,'Name6',94613
1106,'Name16',94612,15000,NULL,'NULL',NULL
1106,'Name16',94612,5000,NULL,'NULL',NULL
1106,'Name16',94616,15000,NULL,'NULL',NULL
1106,'Name16',94616,5000,NULL,'NULL',NULL
1106,'Name6',94612,15000,1006,'Name6',94613
1106,'Name6',94612,5000,1006,'Name6',94613
1106,'Name6',94616,15000,1006,'Name6',94613
1106,'Name6',94616,5000,1006,'Name6',94613
NULL,'NULL',NULL,NULL,1007,'Name7',94614
NULL,'NULL',NULL,NULL,1008,'Name8',94614
NULL,'NULL',NULL,NULL,1009,'Name9',94615
NULL,'NULL',NULL,NULL,1010,'Name10',94615
====
---- QUERY
# join on int
select j.*, d.*
from JoinTbl j inner join DimTbl d on (j.test_zip = d.zip)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1001,'Name1',94611,5000,1002,'Name2',94611
1002,'Name2',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1001,'Name1',94611
1003,'Name3',94611,5000,1002,'Name2',94611
1004,'Name4',94611,5000,1001,'Name1',94611
1004,'Name4',94611,5000,1002,'Name2',94611
1005,'Name5',94611,5000,1001,'Name1',94611
1005,'Name5',94611,5000,1002,'Name2',94611
1006,'Name16',94612,15000,1003,'Name3',94612
1006,'Name16',94612,15000,1004,'Name4',94612
1006,'Name16',94612,5000,1003,'Name3',94612
1006,'Name16',94612,5000,1004,'Name4',94612
1106,'Name16',94612,15000,1003,'Name3',94612
1106,'Name16',94612,15000,1004,'Name4',94612
1106,'Name16',94612,5000,1003,'Name3',94612
1106,'Name16',94612,5000,1004,'Name4',94612
1106,'Name6',94612,15000,1003,'Name3',94612
1106,'Name6',94612,15000,1004,'Name4',94612
1106,'Name6',94612,5000,1003,'Name3',94612
1106,'Name6',94612,5000,1004,'Name4',94612
====
---- QUERY
select j.*, d.*
from JoinTbl j left outer join DimTbl d on (j.test_zip = d.zip)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1001,'Name1',94611,5000,1002,'Name2',94611
1002,'Name2',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1001,'Name1',94611
1003,'Name3',94611,5000,1002,'Name2',94611
1004,'Name4',94611,5000,1001,'Name1',94611
1004,'Name4',94611,5000,1002,'Name2',94611
1005,'Name5',94611,5000,1001,'Name1',94611
1005,'Name5',94611,5000,1002,'Name2',94611
1006,'Name16',94612,15000,1003,'Name3',94612
1006,'Name16',94612,15000,1004,'Name4',94612
1006,'Name16',94612,5000,1003,'Name3',94612
1006,'Name16',94612,5000,1004,'Name4',94612
1006,'Name16',94616,15000,NULL,'NULL',NULL
1006,'Name16',94616,5000,NULL,'NULL',NULL
1006,'Name6',94616,15000,NULL,'NULL',NULL
1006,'Name6',94616,5000,NULL,'NULL',NULL
1106,'Name16',94612,15000,1003,'Name3',94612
1106,'Name16',94612,15000,1004,'Name4',94612
1106,'Name16',94612,5000,1003,'Name3',94612
1106,'Name16',94612,5000,1004,'Name4',94612
1106,'Name16',94616,15000,NULL,'NULL',NULL
1106,'Name16',94616,5000,NULL,'NULL',NULL
1106,'Name6',94612,15000,1003,'Name3',94612
1106,'Name6',94612,15000,1004,'Name4',94612
1106,'Name6',94612,5000,1003,'Name3',94612
1106,'Name6',94612,5000,1004,'Name4',94612
1106,'Name6',94616,15000,NULL,'NULL',NULL
1106,'Name6',94616,5000,NULL,'NULL',NULL
====
---- QUERY
select j.*, d.*
from JoinTbl j right outer join DimTbl d on (j.test_zip = d.zip)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1001,'Name1',94611,5000,1002,'Name2',94611
1002,'Name2',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1001,'Name1',94611
1003,'Name3',94611,5000,1002,'Name2',94611
1004,'Name4',94611,5000,1001,'Name1',94611
1004,'Name4',94611,5000,1002,'Name2',94611
1005,'Name5',94611,5000,1001,'Name1',94611
1005,'Name5',94611,5000,1002,'Name2',94611
1006,'Name16',94612,15000,1003,'Name3',94612
1006,'Name16',94612,15000,1004,'Name4',94612
1006,'Name16',94612,5000,1003,'Name3',94612
1006,'Name16',94612,5000,1004,'Name4',94612
1106,'Name16',94612,15000,1003,'Name3',94612
1106,'Name16',94612,15000,1004,'Name4',94612
1106,'Name16',94612,5000,1003,'Name3',94612
1106,'Name16',94612,5000,1004,'Name4',94612
1106,'Name6',94612,15000,1003,'Name3',94612
1106,'Name6',94612,15000,1004,'Name4',94612
1106,'Name6',94612,5000,1003,'Name3',94612
1106,'Name6',94612,5000,1004,'Name4',94612
NULL,'NULL',NULL,NULL,1005,'Name5',94613
NULL,'NULL',NULL,NULL,1006,'Name6',94613
NULL,'NULL',NULL,NULL,1007,'Name7',94614
NULL,'NULL',NULL,NULL,1008,'Name8',94614
NULL,'NULL',NULL,NULL,1009,'Name9',94615
NULL,'NULL',NULL,NULL,1010,'Name10',94615
====
---- QUERY
select j.*, d.*
from JoinTbl j full outer join DimTbl d on (j.test_zip = d.zip)
---- TYPES
bigint, string, int, int, bigint, string, int
---- RESULTS
1001,'Name1',94611,5000,1001,'Name1',94611
1001,'Name1',94611,5000,1002,'Name2',94611
1002,'Name2',94611,5000,1001,'Name1',94611
1002,'Name2',94611,5000,1002,'Name2',94611
1003,'Name3',94611,5000,1001,'Name1',94611
1003,'Name3',94611,5000,1002,'Name2',94611
1004,'Name4',94611,5000,1001,'Name1',94611
1004,'Name4',94611,5000,1002,'Name2',94611
1005,'Name5',94611,5000,1001,'Name1',94611
1005,'Name5',94611,5000,1002,'Name2',94611
1006,'Name16',94612,15000,1003,'Name3',94612
1006,'Name16',94612,15000,1004,'Name4',94612
1006,'Name16',94612,5000,1003,'Name3',94612
1006,'Name16',94612,5000,1004,'Name4',94612
1006,'Name16',94616,15000,NULL,'NULL',NULL
1006,'Name16',94616,5000,NULL,'NULL',NULL
1006,'Name6',94616,15000,NULL,'NULL',NULL
1006,'Name6',94616,5000,NULL,'NULL',NULL
1106,'Name16',94612,15000,1003,'Name3',94612
1106,'Name16',94612,15000,1004,'Name4',94612
1106,'Name16',94612,5000,1003,'Name3',94612
1106,'Name16',94612,5000,1004,'Name4',94612
1106,'Name16',94616,15000,NULL,'NULL',NULL
1106,'Name16',94616,5000,NULL,'NULL',NULL
1106,'Name6',94612,15000,1003,'Name3',94612
1106,'Name6',94612,15000,1004,'Name4',94612
1106,'Name6',94612,5000,1003,'Name3',94612
1106,'Name6',94612,5000,1004,'Name4',94612
1106,'Name6',94616,15000,NULL,'NULL',NULL
1106,'Name6',94616,5000,NULL,'NULL',NULL
NULL,'NULL',NULL,NULL,1005,'Name5',94613
NULL,'NULL',NULL,NULL,1006,'Name6',94613
NULL,'NULL',NULL,NULL,1007,'Name7',94614
NULL,'NULL',NULL,NULL,1008,'Name8',94614
NULL,'NULL',NULL,NULL,1009,'Name9',94615
NULL,'NULL',NULL,NULL,1010,'Name10',94615
====
---- QUERY
# semi-join on bigint
select d.*
from DimTbl d left semi join JoinTbl j on (d.id = j.test_id)
---- TYPES
bigint, string, int
---- RESULTS
1001,'Name1',94611
1002,'Name2',94611
1003,'Name3',94612
1004,'Name4',94612
1005,'Name5',94613
1006,'Name6',94613
====
---- QUERY
# semi-join on string
select d.*
from DimTbl d left semi join JoinTbl j on (j.test_name = d.name)
---- TYPES
bigint, string, int
---- RESULTS
1001,'Name1',94611
1002,'Name2',94611
1003,'Name3',94612
1004,'Name4',94612
1005,'Name5',94613
1006,'Name6',94613
====
---- QUERY
# semi-join on int
select d.*
from DimTbl d left semi join JoinTbl j on (j.test_zip = d.zip)
---- TYPES
bigint, string, int
---- RESULTS
1001,'Name1',94611
1002,'Name2',94611
1003,'Name3',94612
1004,'Name4',94612
====
---- QUERY
# joins on empty tables
select * from emptytable t1 full outer join emptytable t2 on (t1.field=t2.field)
---- TYPES
string, int, string, int
---- RESULTS
====
---- QUERY
select count(*) from emptytable t1 right outer join greptiny t2 on (t1.field=t2.field)
---- TYPES
bigint
---- RESULTS
100
====
---- QUERY
select count(*) from greptiny t1 left outer join emptytable t2 on (t1.field=t2.field)
---- TYPES
bigint
---- RESULTS
100
====
---- QUERY
# test nested joins
select a.id, b.id, c.id, a.day, b.day, c.month, a.month, b.month
from alltypesagg a join alltypesagg b on
(a.id = b.id and a.month = b.day and b.month = 1 and b.month = b.day and a.day = b.day)
left outer join alltypessmall c on
(c.id = a.id and a.month = c.id and a.month=c.month)
where a.id < 10
---- TYPES
int, int, int, int, int, int, int, int
---- RESULTS
0,0,NULL,1,1,NULL,1,1
1,1,1,1,1,1,1,1
2,2,NULL,1,1,NULL,1,1
3,3,NULL,1,1,NULL,1,1
4,4,NULL,1,1,NULL,1,1
5,5,NULL,1,1,NULL,1,1
6,6,NULL,1,1,NULL,1,1
7,7,NULL,1,1,NULL,1,1
8,8,NULL,1,1,NULL,1,1
9,9,NULL,1,1,NULL,1,1
====
---- QUERY
# test full outer join where the RHS is empty and the LHS has a very low selectivity
# test query filed in IMP-791
SELECT a.string_col ts2
FROM alltypes a
FULL OUTER JOIN (
select * from alltypessmall where id < 0
) b
ON a.id=b.id AND a.id = 1
ORDER BY ts2 DESC LIMIT 10;
---- TYPES
string
---- RESULTS
'1'
====
---- QUERY
# test nullable expressions from inline views in left outer join
select x.id, y.a, y.b, y.id from alltypestiny x left outer join
(select 10 as a, case when id is null then 11 else 12 end as b, id from alltypestiny)
y on x.id = (y.id % 2)
order by x.id, y.id limit 100
---- TYPES
int, tinyint, tinyint, int
---- RESULTS
0,10,12,0
0,10,12,2
0,10,12,4
0,10,12,6
1,10,12,1
1,10,12,3
1,10,12,5
1,10,12,7
2,NULL,NULL,NULL
3,NULL,NULL,NULL
4,NULL,NULL,NULL
5,NULL,NULL,NULL
6,NULL,NULL,NULL
7,NULL,NULL,NULL
====
---- QUERY
# test nullable expressions from inline views in full outer join
select x.a, x.b, x.id, y.a, y.b, y.id from
(select 10 as a, case when id is null then 11 else 12 end as b, id from alltypestiny) x
full outer join
(select 20 as a, case when id is null then 21 else 22 end as b, id from alltypestiny) y on x.id = (y.id + 4)
order by x.id, y.id limit 100
---- TYPES
tinyint, tinyint, int, tinyint, tinyint, int
---- RESULTS
10,12,0,NULL,NULL,NULL
10,12,1,NULL,NULL,NULL
10,12,2,NULL,NULL,NULL
10,12,3,NULL,NULL,NULL
10,12,4,20,22,0
10,12,5,20,22,1
10,12,6,20,22,2
10,12,7,20,22,3
NULL,NULL,NULL,20,22,4
NULL,NULL,NULL,20,22,5
NULL,NULL,NULL,20,22,6
NULL,NULL,NULL,20,22,7
====
---- QUERY
# test nullable expressions wrapped multiple times
select z.xa, z.xid, z.ya, z.yid, k.a, k.id from
(select x.a as xa, x.id as xid, y.a as ya, y.id as yid from
(select 10 as a, id from alltypestiny where id = 1) x
full outer join
(select 20 as a, id from alltypestiny where id = 1) y on x.id = (y.id + 2)
) z
full outer join
(select 30 as a, id from alltypestiny where id = 1) k on z.xid = (k.id + 3)
order by z.xid, z.yid, k.id limit 100
---- TYPES
tinyint, int, tinyint, int, tinyint, int
---- RESULTS
10,1,NULL,NULL,NULL,NULL
NULL,NULL,20,1,NULL,NULL
NULL,NULL,NULL,NULL,30,1
====
---- QUERY
# right outer join requires the join op to be partitioned, otherwise non-matches cause
# duplicates
select count(*)
from functional.alltypesagg a
right outer join functional.alltypestiny b on (a.tinyint_col = b.id)
where a.tinyint_col is null
---- TYPES
bigint
---- RESULTS
1
====
---- QUERY
# same for full outer joins
select count(*)
from functional.alltypesagg a
full outer join functional.alltypestiny b on (a.tinyint_col = b.id)
where a.tinyint_col is null
---- TYPES
bigint
---- RESULTS
1001
====
---- QUERY
# test multiple outer joins with an inline view to check that nullable tuples
# are properly sent over the network
select z.xid, z.yid, k.id from
(select x.id as xid, y.id as yid from
(select id from alltypestiny where id = 1) x
full outer join
(select id from alltypestiny where id = 1) y on x.id = (y.id + 2)
) z
full outer join
(select id from alltypestiny where id = 1) k on z.xid = (k.id + 3)
order by z.xid, z.yid, k.id limit 100
---- TYPES
int, int, int
---- RESULTS
1,NULL,NULL
NULL,1,NULL
NULL,NULL,1
====
---- QUERY
# test that right outer join includes tuples from rhs
# even if one of its join columns is NULL
select count(*) from functional.alltypesagg a
right outer join functional.alltypesagg b on a.int_col = b.int_col
where b.int_col is null
---- TYPES
bigint
---- RESULTS
10
====
---- QUERY
# test that full outer join includes tuples from rhs
# even if one of its join columns is NULL
select count(*) from functional.alltypesagg a
full outer join functional.alltypesagg b on a.int_col = b.int_col
where a.int_col is null or b.int_col is null
---- TYPES
bigint
---- RESULTS
20
====
---- QUERY
# Regression test for IMPALA-676, which exposed a bug in our codegen subexpresssion
# elimination logic.
select count(*) from alltypesagg a
left outer join alltypesagg b
on (a.id = b.id
and (a.int_col = b.int_col + 10000 or (a.int_col is null and b.int_col is null)))
where b.id is not null
---- TYPES
bigint
---- RESULTS
10
====
---- QUERY
# Regression test for IMPALA-735.
select distinct t1.tinyint_col from alltypesagg t1
full outer join alltypesagg t2
on t2.smallint_col = (t1.tinyint_col + 10000)
---- TYPES
tinyint
---- RESULTS
NULL
1
2
3
4
5
6
7
8
9
====
---- QUERY
# Regression test for IMPALA-904. Tests correct execution of exprs from an outer-joined
# inline view that can evaluate to a non-NULL value with NULL-valued slots. Use an
# explicit [shuffle] hint for extra coverage because the expr will also be evaluated in
# a hashing data sink.
select count(*) from functional.alltypestiny t1 left outer join [shuffle]
(select zeroifnull(int_col) as id from functional.alltypessmall) t2 on (t1.id = t2.id)
---- TYPES
bigint
---- RESULTS
8
====