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


##########
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:
   OK, sounds good. Maybe just cross check your expected results with another 
DBMS (e.g., Postgres) just to be sure that things work as expected.



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