private Set<String> getQualifiedAliases(JoinOperator op, RowSchema rs) {
      Set<String> aliases = new HashSet<String>();
      JoinCondDesc[] conds = op.getConf().getConds();
      Map<Integer, Set<String>> posToAliasMap = op.getPosToAliasMap();
      int i;
      for (i=conds.length-1; i>=0; i--){
        if (conds[i].getType() == JoinDesc.INNER_JOIN) {
          aliases.addAll(posToAliasMap.get(i+1));
        } else if (conds[i].getType() == JoinDesc.FULL_OUTER_JOIN) {
          break;
        } else if (conds[i].getType() == JoinDesc.RIGHT_OUTER_JOIN) {
          aliases.addAll(posToAliasMap.get(i+1));
          break;
        } else if (conds[i].getType() == JoinDesc.LEFT_OUTER_JOIN) {
          continue;
        }
      }
      if(i == -1){
        aliases.addAll(posToAliasMap.get(0));
      }
      Set<String> aliases2 = rs.getTableNames();
      aliases.retainAll(aliases2);
      return aliases;
    }
Figures out the aliases for whom it is safe to push predicates based on
ANSI SQL semantics. The join conditions are left associative so "a
RIGHT OUTER JOIN b LEFT OUTER JOIN c INNER JOIN d" is interpreted as
"((a RIGHT OUTER JOIN b) LEFT OUTER JOIN c) INNER JOIN d".  For inner
joins, both the left and right join subexpressions are considered for
pushing down aliases, for the right outer join, the right subexpression
is considered and the left ignored and for the left outer join, the
left subexpression is considered and the left ignored. Here, aliases b
and d are eligible to be pushed up.

TODO: further optimization opportunity for the case a.c1 = b.c1 and b.c2
= c.c2 a and b are first joined and then the result with c. But the
second join op currently treats a and b as separate aliases and thus
disallowing predicate expr containing both tables a and b (such as a.c3
+ a.c4 > 20). Such predicates also can be pushed just above the second
join and below the first join

@param op
         Join Operator
@param rr
         Row resolver
@return set of qualified aliases
ql/src/java/org/apache/hadoop/hive/ql/ppd/OpProcFactory.java