IMPALA-11567: Fix left outer join if the right side is subquery with complex type

Non-matching rows from the left side will null out all slots from the
right side in left outer joins. If the right side is a subquery, it
is possible that some returned expressions will be non-NULL even if all
slots are NULL (e.g. constants) - these expressions are wrapped as
IF(TupleIsNull(tids), NULL, expr) to null them in the non-matching
case.

The logic above used to hit a precondition for complex types. We can
safely ignore complex types for now, as currently the only possible
expression that returns a complex type is SlotRef, which doesn't
need to be wrapped. We will have to revisit this once functions are
added that return complex types.

Testing:
- added a regression  test and ran it

Change-Id: Iaa8991cd4448d5c7ef7f44f73ee07e2a2b6f37ce
Reviewed-on: http://gerrit.cloudera.org:8080/18954
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
Csaba Ringhofer
2022-09-08 15:55:46 +02:00
committed by Impala Public Jenkins
parent 5aff120c40
commit 2e1ce445b2
2 changed files with 22 additions and 2 deletions

View File

@@ -391,4 +391,18 @@ select id, arr_int_1d, arr_int_2d, arr_int_3d, arr_string_1d, arr_string_2d, arr
1,'[1,2,NULL]','[[1,2,NULL],[3]]','[[[1,2,NULL],[3]],[[4]]]','["1","2",NULL]','[["1","2",NULL],["3"]]','[[["1","2",NULL],["3"]],[["4"]]]'
---- TYPES
INT,STRING,STRING,STRING,STRING,STRING,STRING
====
---- QUERY
# Regression test for:
# IMPALA-11567: "Error in left outer join if the right side is a subquery with complex types"
select a.id, b.arr_int_1d, b.arr_int_2d
from alltypestiny a left outer join
(select id, arr_int_1d, arr_int_2d from collection_tbl) b
on a.id = b.id where a.id < 3;
---- RESULTS
0,'NULL','NULL'
1,'[1,2,NULL]','[[1,2,NULL],[3]]'
2,'NULL','NULL'
---- TYPES
INT,STRING,STRING
=====