zabetak commented on code in PR #4478:
URL: https://github.com/apache/hive/pull/4478#discussion_r1268213110
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java:
##########
@@ -2795,6 +2802,58 @@ private RelNode genJoinRelNode(RelNode leftRel, String
leftTableAlias, RelNode r
return topRel;
}
+ /**
+ * This method searches for columnName in the left row resolver tables,
and returns
+ * the right most tableAlias containing the column.
+ *
+ * For example, if we have 3 tables with the following schemas:
+ * <p><b>t1 - (a), t2 - (a, b), t3 - (a, b, c)</b></p>
+ *
+ * and we were trying to run the following query:
+ * <p>
+ * <b>select * from t1
+ * join t2 using(a)
+ * join t3 using(a);
+ * </b>
+ * </p>
+ * For the second join, this method will return t2 instead of t1 as t2 is
the rightmost table
+ * containing column a.
+ *
+ * And, for the query:
+ * <p>
+ * <b>
+ * select * from t2
+ * join t1 using(a)
+ * join t3 using(b);
+ * </b>
+ * </p>
+ *
+ * For the second join, this method will return t2 (which is the first
table on the left) as column
+ * b is in t2 and not t1.
+ *
+ * @param leftRR left RowResolver
+ * @param columnName name of the column in the using clause
+ * @return leftTableAlias
+ * @throws SemanticException SemanticException is thrown when columnName
is not present
+ * in any table
+ */
+ private String getLeftTableAlias(RowResolver leftRR, String columnName)
throws SemanticException {
Review Comment:
This method is quite generic but the naming and description are "left"
biased :)
Thinking a bit more this method would fit better inside the `RowResolver`
class; in fact there may be one already there so worth double checking before
we introduce a new one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]