Skip to content

Commit

Permalink
IMPALA-2018: Where clause does not propagate to joins inside nested
Browse files Browse the repository at this point in the history
views

This commit fixes an issue where during predicate propagation a
predicate from the where clause is not properly assigned at the join
node that outer joins the generated predicate.

Change-Id: Ifccc1b0e0a0579c3baa48f0fb3dedcbd44941b53
Reviewed-on: http://gerrit.cloudera.org:8080/476
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Internal Jenkins
  • Loading branch information
dtsirogiannis authored and Internal Jenkins committed Jun 26, 2015
1 parent d4c8050 commit 07cd53c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
12 changes: 9 additions & 3 deletions fe/src/main/java/com/cloudera/impala/analysis/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1386,9 +1386,15 @@ public ArrayList<Expr> getBoundPredicates(TupleId destTid, Set<SlotId> ignoreSlo
}
}

boolean evalByJoin = evalByJoin(srcConjunct) &&
(globalState_.ojClauseByConjunct.get(srcConjunct.getId())
!= globalState_.outerJoinedTupleIds.get(srcTid));
// Check if either srcConjunct or the generated predicate needs to be evaluated
// at a join node (IMPALA-2018).
boolean evalByJoin =
(evalByJoin(srcConjunct)
&& (globalState_.ojClauseByConjunct.get(srcConjunct.getId())
!= globalState_.outerJoinedTupleIds.get(srcTid)))
|| (evalByJoin(p)
&& (globalState_.ojClauseByConjunct.get(p.getId())
!= globalState_.outerJoinedTupleIds.get(destTid)));

// mark all bound predicates including duplicate ones
if (reverseValueTransfer && !evalByJoin) markConjunctAssigned(srcConjunct);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1120,3 +1120,48 @@ where b.id < 10
partitions=24/24 files=24 size=478.45KB
predicates: id > 20, functional.alltypes.id < 10
====
# Test proper predicate assignment with predicate propagation when the
# generated predicate is bound by an outer joined tuple (IMPALA-2018)
select * from
(select j.int_col, sum(j.tinyint_col) as total from
(select a.id, a.tinyint_col, b.int_col from
functional.alltypestiny a left outer join functional.alltypesagg b
on a.id = b.id) j
group by j.int_col) v
where v.int_col = 10
---- PLAN
03:AGGREGATE [FINALIZE]
| output: sum(a.tinyint_col)
| group by: b.int_col
| having: j.int_col = 10
|
02:HASH JOIN [RIGHT OUTER JOIN]
| hash predicates: b.id = a.id
|
|--00:SCAN HDFS [functional.alltypestiny a]
| partitions=4/4 files=4 size=460B
|
01:SCAN HDFS [functional.alltypesagg b]
partitions=11/11 files=11 size=814.73KB
predicates: b.int_col = 10
====
# Test proper predicate assignment with predicate propagation when the
# generated predicate is bound by an outer joined tuple (IMPALA-2018)
select * from
(select j.int_col, j.tinyint_col from
(select a.id, a.tinyint_col, b.int_col from
functional.alltypestiny a left outer join functional.alltypesagg b
on a.id = b.id) j) v
where v.int_col = 10
---- PLAN
02:HASH JOIN [RIGHT OUTER JOIN]
| hash predicates: b.id = a.id
| other predicates: b.int_col = 10
|
|--00:SCAN HDFS [functional.alltypestiny a]
| partitions=4/4 files=4 size=460B
|
01:SCAN HDFS [functional.alltypesagg b]
partitions=11/11 files=11 size=814.73KB
predicates: b.int_col = 10
====

0 comments on commit 07cd53c

Please sign in to comment.