IMPALA-2946: Fix query flattening in Qgen
IMPALA-2946: Fix query flattening in Qgen

If a correlated collection appears in the JOIN clause, it needs to be
converted to an inline view, but in some cases this does not happen.
This patch fixes the problem.

Before this patch, a query that looks similar to this would be
rewritten incorrectly. In particular l1 would not be rewritten as an
inline view because it is in the join clause of an inline view.
SELECT
  ...
FROM
  customer c1
WHERE
  (...) IN (
    SELECT
      ...
    FROM
      c1.orders o1
      INNER JOIN c1.orders.lineitems l1 ON (...)

After this patch, l1 will be rewriten as:
(
  SELECT
    l1.*
  FROM
    orders tmp_alias_1
    INNER JOIN lineitem l1
      ON ([l1 is child of tmp_alias_1])
  WHERE
    ([tmp_alias_1 is child of c1])
) l1

Change-Id: I1956d9e3252c9a91b79e69cf55d79f55cc1f0e4f
Reviewed-on: http://gerrit.cloudera.org:8080/2056
Reviewed-by: Casey Ching <77bc9a9984e6786c5799d7a71768cf023120ef76@cloudera.com>
Tested-by: Internal Jenkins

kapilrastogi/Impala,kapilrastogi/Impala,kapilrastogi/Impala,kapilrastogi/Impala,kapilrastogi/Impala,kapilrastogi/Impala,kapilrastogi/Impala