Skip to content

fix: move overflow guard before dense ratio in hash join to prevent overflows#20998

Open
buraksenn wants to merge 4 commits intoapache:mainfrom
buraksenn:fix-hash-join-overflow
Open

fix: move overflow guard before dense ratio in hash join to prevent overflows#20998
buraksenn wants to merge 4 commits intoapache:mainfrom
buraksenn:fix-hash-join-overflow

Conversation

@buraksenn
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

#20995 has details but it is very straightforward. dense_ratio calculation overflows since overflow guard is after not before

What changes are included in this PR?

Prevent hash join overflow and unit test for it

Are these changes tested?

Added a test case for both min and max scenario

@github-actions github-actions bot added the physical-plan Changes to the physical-plan crate label Mar 17, 2026
@mbutrovich mbutrovich self-requested a review March 17, 2026 15:18
@mbutrovich
Copy link
Contributor

Why isn't this running the full CI suite?

@buraksenn
Copy link
Contributor Author

Why isn't this running the full CI suite?

I did not understand its the first time I've encountered this after my first PR

@mbutrovich
Copy link
Contributor

I'll keep merging in main and hope that it kicks off the right CI checks.

@mbutrovich
Copy link
Contributor

Blocked on #21002.

github-merge-queue bot pushed a commit that referenced this pull request Mar 17, 2026
….1.0 (#20980)" (#21002)

This reverts commit 11b9693.

## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->

- Closes #.

## Rationale for this change

I noticed CI is not running on this PR opened today:
#20998

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->

See related Comet discussion at
apache/datafusion-comet#3684 (comment)

> <img alt="image" width="1875" height="418"
src="https://private-user-images.githubusercontent.com/19199204/564414382-56caab4b-20d9-4d7b-b1ef-11de17ded2bc.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzM3NjM4MjUsIm5iZiI6MTc3Mzc2MzUyNSwicGF0aCI6Ii8xOTE5OTIwNC81NjQ0MTQzODItNTZjYWFiNGItMjBkOS00ZDdiLWIxZWYtMTFkZTE3ZGVkMmJjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzE3VDE2MDUyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVlOTAxYzhmNjFjMzEwZWMzY2E3M2JhMWVjYzUwZjBiY2IxN2NlNzdkYjNkN2MwMzFkZDllZjJiMzk1YTUzYWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.IwLJ7-JDMYMr6qcO0WWHRsUgRhios73KuMl1a41nN2k">
> ASF blocks non-approved actions inside apache organization (by hash),
so you either need to add it to
https://github.com/apache/infrastructure-actions or rollback the update

We're now seeing it in DF as well:

<img width="865" height="335" alt="Screenshot 2026-03-17 at 12 06 22 PM"
src="https://github.com/user-attachments/assets/668a1dda-bf79-42f4-9472-acf8f7b3895e"
/>


## What changes are included in this PR?

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

- Revert #20980 

## Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

Existing tests (make sure they actually run).

## Are there any user-facing changes?

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

-No.

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
@mbutrovich
Copy link
Contributor

mbutrovich commented Mar 17, 2026

I would like to test this change back-ported into a branch-53 to test with Comet (which found the original issue when testing branch-53). Please give me a few hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Perfect hash join panics with overflow on full-range signed integer keys

2 participants