soumyakanti3578 commented on code in PR #4478:
URL: https://github.com/apache/hive/pull/4478#discussion_r1268518775


##########
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
+            // column columnName
+            if (leftTableAlias == null) {
+              Map<String, Map<String, ColumnInfo>> leftRslvMap = 
leftRR.getRslvMap();
+              for (String tableAlias: leftRR.getTableNames()) {
+                if (!leftRslvMap.containsKey(tableAlias)) {
+                  continue;
+                }
+                if (leftRslvMap.get(tableAlias).containsKey(columnName)) {
+                  leftTableAlias = tableAlias;

Review Comment:
   On postgres, it looks like a cost based decision. Every plan is not exactly 
the same, and the choice for table alias depends on other factors, like if it 
is a self join or not.



-- 
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]

Reply via email to