lyne7-sc opened a new pull request, #26771: URL: https://github.com/apache/datafusion/pull/26771
> [!IMPORTANT] > > **Fork CI setup:** For pull requests from a fork to `main`, enable workflows in your fork's **Actions** tab before you push. > See the [fork CI setup guide](https://datafusion.apache.org/contributor-guide/#pull-requests-from-forks). ## 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 <!-- 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. Please explain the problem you are trying to solve in terms of the user-visible behavior, rather than the implementation. For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of the implementation. "COUNT(DISTINCT) returns wrong results when the column contains nulls" is the user-visible problem. --> Left semi, left anti, and left mark nested loop joins only need to determine whether each left row has a match. After a match is found, subsequent right batches can still evaluate the join predicate for that left row. Skipping this redundant work reduces query time when many left rows match before the right input is exhausted. ## 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. --> - Use the existing match bitmap to advance past matched left rows before probing. Cache consecutive unmatched ranges of up to 64 rows to amortize bitmap locking, while preserving vectorized probes for small right batches. - Stop fetching right batches once all left rows have matched. Disable this early termination during spill execution, which must record the right input for replay against later left chunks. - Extend existence-join and spill slts, and add Q24/Q25 benchmarks for left semi/anti joins with no matches. ## What is the testing strategy for this PR? <!-- 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 Briefly describe how this PR is tested, and point to the specific tests you added. For example: 'This new feature is covered by the `sqllogictest` cases added in `foo.slt`'. If this PR does not add tests, explain why. For example, if the change is already covered by existing tests, please mention it. You should also check the `codecov` bot reply on this PR to confirm the changed code is exercised. --> - Extend `nested_loop_join_existence.slt` with left semi/anti/mark cases covering sparse survivors, original payload indices, NULLs, multiple right batches, an unconditional predicate, and empty right input. Add execution-metric assertions showing that all three join types consume only one right batch after every left row matches, using 65 left rows to exercise the bitmap tail. - Extend `nested_loop_join_spill.slt` with a left semi join whose first left chunk matches immediately, checking that subsequent chunks still receive the recorded right input. ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. If there are any breaking changes to public APIs, please add the `api change` label. --> This is an internal performance improvement. Query results and public APIs are unchanged. ## NLJ Benchmark | Query | Join type | Scenario | Main (ms) | Candidate (ms) | Time change | |---|---|---|---:|---:|---:| | Q13 | LeftSemi | 30K × 30K; almost all left rows match | 91.771 | 53.817 | -41.36% | | Q14 | LeftAnti | Same inputs and predicate as Q13 | 94.654 | 53.296 | -43.69% | | Q17 | LeftMark | 30K-row inputs; correlated EXISTS | 92.098 | 75.061 | -18.50% | | Q24 | LeftSemi | No matches; no skipping or early termination | 7.450 | 7.327 | -1.64% | | Q25 | LeftAnti | No matches; no skipping or early termination | 7.520 | 7.480 | -0.53% | -- 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]
