mirror of
https://github.com/apache/impala.git
synced 2026-02-02 15:00:38 -05:00
When set ENABLE_OUTER_JOIN_TO_INNER_TRANSFORMATION = true, the planner will simplify outer joins if the WHERE clause contains at least one null rejecting condition and then remove the outer-joined tuple id from the map of GlobalState#outerJoinedTupleIds. However, there may be false removals for right join simplification or full join simplification. This may lead to incorrect results since it is incorrect to propagate a non null-rejecting predicate into a plan subtree that is on the nullable side of an outer join. GlobalState#outerJoinedTupleIds indicates whether a table is on the nullable side of an outer join. E.g. SELECT COUNT(*) FROM functional.nullrows t1 FULL JOIN functional.nullrows t2 ON t1.id = t2.id FULL JOIN functional.nullrows t3 ON coalesce(t1.id, t2.id) = t3.id WHERE t1.group_str = 'a' AND coalesce(t2.group_str, 'f') = 'f' The predicate coalesce(t2.group_str, 'f') = 'f' will propagate into t2 if we remove t2 from GlobalState#outerJoinedTupleIds. Testing: - Add new plan tests in outer-to-inner-joins.test - Add new query tests to verify the correctness on transformation Change-Id: I6565c5bff0d2f24f30118ba47a2583383e83fff7 Reviewed-on: http://gerrit.cloudera.org:8080/19116 Reviewed-by: Qifan Chen <qfchen@hotmail.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>