Skip to content

Conversation

@kasakrisz
Copy link
Contributor

@kasakrisz kasakrisz commented Nov 7, 2025

What changes were proposed in this pull request?

The CommonJoinOperator implements several types of joins: inner, outer, and anti joins. It also supports binary and n-way joins, and combinations of these. The operator fetches and buffers rows from each join input. After the required input rows are present, the operator constructs the joined rows and forwards them. In the case of an anti join, a joined row is forwarded when the right input is empty. For binary joins this logic is already present. For n-way joins the logic works only when none of the other joins are outer joins.
This pull request extends support for anti joins mixed with outer joins.

Why are the changes needed?

The current implementation does not recognize when an n-way join contains both anti and outer joins; it therefore constructs and forwards rows even if the right side of an anti join has rows, which leads to incorrect results.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

mvn test -Dtest.output.overwrite -Dtest=TestMiniLlapLocalCliDriver -Dqfile=antijoin3.q -pl itests/qtest -Pitests

@kasakrisz kasakrisz marked this pull request as draft November 7, 2025 12:27
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 7, 2025

@kasakrisz kasakrisz marked this pull request as ready for review November 10, 2025 13:17
Copy link
Contributor

@ngsg ngsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch looks good to me, +1. I have checked that the master branch returns an incorrect result for antijoin3.q, and IIUC, the patch introduces only minimal changes to correctly handle AntiJoin + OuterJoin, which was probably missed in the previous AntiJoin implementation.

BTW, there is a typo in the title (resutls -> results), which likely comes from the JIRA.

@kasakrisz kasakrisz changed the title HIVE-29290: Enabling "hive.merge.nway.joins" returns wrong resutls HIVE-29290: Enabling "hive.merge.nway.joins" returns wrong results Nov 11, 2025
@kasakrisz kasakrisz changed the title HIVE-29290: Enabling "hive.merge.nway.joins" returns wrong results HIVE-29290: Wrong results when n-way join contains both anti and outer join Nov 11, 2025
@kasakrisz
Copy link
Contributor Author

@ngsg
Thank you for the review. I rewrote the jira and PR summary.

@kasakrisz kasakrisz merged commit c054a47 into apache:master Nov 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants