kasakrisz commented on code in PR #5998: URL: https://github.com/apache/hive/pull/5998#discussion_r2257017348
########## 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: Can `HiveRelShuttleImpl` be used instead of `RelHomogeneousShuttle` to get rid of `rel instanceof <Something>`? -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org