Repository navigation
fix: stop probing at the fetch limit when the hash join build map is empty - #27750
Aaravkhanal wants to merge 2 commits into
Conversation
mbutrovich
left a comment
There was a problem hiding this comment.
Thanks @Aaravkhanal. The fix matches how the non-empty path already handles LimitReached (stream.rs).
Since #27399, this branch of HashJoinStream runs in fewer cases than the PR description suggests. On the default config, inner, left, right, and full joins go to BatchedJoinProcessor (RegularJoinKind::from_join_type), which already stops at the limit (batched_join_processor.rs). The only join types that emit rows from this empty-map branch are RightAnti and RightMark. Right and Full reach it only with datafusion.execution.enable_migration_hash_join = false (config.rs). The stream isn't deprecated: its module docs say semi, anti, mark, and null-aware joins still use it by default (stream.rs). So the fix is worth having until existence joins move to their own stream (#26361). Could you name these join types in the "Are there any user-facing changes?" section, so readers of the changelog know which queries change?
Co-authored-by: Matt Butrovich <6855576+mbutrovich@users.noreply.github.com>
Which issue does this PR close?
Closes #27726.
Rationale for this change
A hash join with a pushed-down limit can keep reading probe batches after it has found enough rows when the build map is empty.
What changes are included in this PR?
Finish the output buffer when this path reaches the fetch limit. This flushes buffered rows and stops the stream before it polls the probe input again.
What is the testing strategy for this PR?
The regression test covers right anti and right mark joins, each with an empty build input and an input containing only a NULL key. Each case checks the returned probe values and fails if the join polls the probe again after reaching the limit. All 697 hash-join tests passed locally with the expanded coverage.
Are there any user-facing changes?
With the default configuration, right anti and right mark hash joins with an empty build map stop scanning the probe input once the pushed-down limit is satisfied. The same change applies to right and full hash joins when
datafusion.execution.enable_migration_hash_join = false.Assisted-by: OpenAI Codex