soumyakanti3578 commented on code in PR #4478:
URL: https://github.com/apache/hive/pull/4478#discussion_r1265680863
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java:
##########
@@ -2631,6 +2631,21 @@ private RelNode genJoinRelNode(RelNode leftRel, String
leftTableAlias, RelNode r
unparseTranslator.addIdentifierTranslation((ASTNode) child);
}
namedColumns.add(columnName);
+
+ // if leftTableAlias is null, set it to the last tableAlias that
contains the
Review Comment:
I think this is exactly what's happening now. For the second join, I try to
find the right most (last) table containing the column name. Note that
`leftRR.getTableNames()` returns the tables in order as it is a
`LinkedHashMap#keySet`.
We can also see the same in the generated optimized sql,
[here](https://github.com/apache/hive/pull/4478/files#diff-b95714ea51eebdd9e91612e7927d98ee8258a47d033535ce28f6a25ae5db620cR107).
For the second join, the right most table `t2` is selected over `t0` in `ON
t2.a = t4.a`.
> POSTHOOK: query: explain extended select * from test t1
join test t2 using(a)
join test t3 using(a)
POSTHOOK: type: QUERY
POSTHOOK: Input: default@test
>#### A masked pattern was here ####
>OPTIMIZED SQL: SELECT `t2`.`a`
FROM (SELECT `a`
FROM `default`.`test`
WHERE `a` IS NOT NULL) AS `t0`
INNER JOIN (SELECT `a`
FROM `default`.`test`
WHERE `a` IS NOT NULL) AS `t2` ON `t0`.`a` = `t2`.`a`
INNER JOIN (SELECT `a`
FROM `default`.`test`
WHERE `a` IS NOT NULL) AS `t4` ON `t2`.`a` = `t4`.`a`
--
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]