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


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java:
##########
@@ -230,6 +225,47 @@ private static void convertOpTree(RelNode rel, RelNode 
parent) {
     }
   }
 
+  /**
+   * A handler that detects self-joins in the plan and rewrites them to 
resolve ambiguous aliases.
+   * The handler traverses the plan and collects aliases of tables it 
encounters for each join branch.
+   * When the same alias occurs in both branches of a join, it introduces a 
derive table (Project)
+   * over the left branch to break the ambiguity.
+   */
+  private static class SelfJoinHandler extends RelHomogeneousShuttle {
+    private final Set<String> aliases = new HashSet<>();
+
+    @Override
+    public RelNode visit(final RelNode rel) {
+      if (rel instanceof Join join) {

Review Comment:
   @kasakrisz I applied your suggestion in 
https://github.com/apache/hive/pull/5998/commits/b12cff8cfbff6453e41fda561e9241c0b3a0cb67
 and tests are again green. Please take another look when you find some 
bandwitdth.



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