You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "kumarUjjawal (via GitHub)" <gi...@apache.org> on 2025/11/18 12:07:44 UTC

[PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

kumarUjjawal opened a new pull request, #18800:
URL: https://github.com/apache/datafusion/pull/18800

   
   ## 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 #18787.
   
   ## Rationale for this change
   
   Sort-merge joins assumed both inputs had the same width when applying filter results. With different column counts (like right-anti joins) we built batches that no longer matched the output schema, so Arrow panicked during concat_batches.
   
   <!--
    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.  
   -->
   
   ## What changes are included in this PR?
   
   - Fix the null-row and filtered-row builders in SortMergeJoinStream to slice the streamed vs buffered columns using the correct widths, keeping every batch consistent with self.schema.
   - Merge the semi/anti projection branch so it always projects the streamed-side columns expected in the output.
   
   <!--
   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.
   -->
   
   ## Are these changes tested?
   
   Manual testing and ran previous tests. 
   
   <img width="1092" height="552" alt="Screenshot 2025-11-18 at 5 04 20 PM" src="https://github.com/user-attachments/assets/1272a368-f694-4d7b-907b-b605a4996419" />
   
   <!--
   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)?
   -->
   
   ## 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 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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton commented on code in PR #18800:
URL: https://github.com/apache/datafusion/pull/18800#discussion_r2542634644


##########
datafusion/physical-plan/src/joins/sort_merge_join/stream.rs:
##########
@@ -1566,6 +1566,7 @@ impl SortMergeJoinStream {
                         .columns()
                         .iter()
                         .skip(right_columns_length)
+                        .take(left_columns_length)

Review Comment:
   what other columns are there?



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton commented on PR #18800:
URL: https://github.com/apache/datafusion/pull/18800#issuecomment-3548676322

   Looks like this include fixes created by, let's wait for it to be merged
   - #18772 
   
   Also, once merged can you update the fuzz tests for join:
   similar to what he added here but add the for loop to the other tests as well:
   `test_right_semi_join_1k_filtered`, `test_right_anti_join_1k_filtered`, `test_right_anti_join_1k_binary`, `test_right_anti_join_1k_binary_filtered`
   https://github.com/apache/datafusion/pull/18772/files#diff-f8330244c576c142337679ecbeeb99e9016c2c7c54d7bae492144374e138a0b7


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

Posted by "kumarUjjawal (via GitHub)" <gi...@apache.org>.
kumarUjjawal commented on code in PR #18800:
URL: https://github.com/apache/datafusion/pull/18800#discussion_r2542980284


##########
datafusion/physical-plan/src/joins/sort_merge_join/stream.rs:
##########
@@ -1566,6 +1566,7 @@ impl SortMergeJoinStream {
                         .columns()
                         .iter()
                         .skip(right_columns_length)
+                        .take(left_columns_length)

Review Comment:
   Right, should I Drop the `.take(left_columns_length)` and add a sanity check like `assert_eq_or_internal_err!(..., left_columns_length, "..."))` before extending right_columns.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

Posted by "kumarUjjawal (via GitHub)" <gi...@apache.org>.
kumarUjjawal commented on PR #18800:
URL: https://github.com/apache/datafusion/pull/18800#issuecomment-3548784067

   > also, when fixing a bug, we require tests to be added that failed on main and pass on this pr
   
   Sure will do.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton commented on PR #18800:
URL: https://github.com/apache/datafusion/pull/18800#issuecomment-3548689479

   also, when fixing a bug, we require tests to be added that failed on main and pass on this pr


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton merged PR #18800:
URL: https://github.com/apache/datafusion/pull/18800


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton commented on code in PR #18800:
URL: https://github.com/apache/datafusion/pull/18800#discussion_r2585470232


##########
datafusion/physical-plan/src/joins/sort_merge_join/stream.rs:
##########
@@ -1566,6 +1566,7 @@ impl SortMergeJoinStream {
                         .columns()
                         .iter()
                         .skip(right_columns_length)
+                        .take(left_columns_length)

Review Comment:
   Yes



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton commented on code in PR #18800:
URL: https://github.com/apache/datafusion/pull/18800#discussion_r2542634644


##########
datafusion/physical-plan/src/joins/sort_merge_join/stream.rs:
##########
@@ -1566,6 +1566,7 @@ impl SortMergeJoinStream {
                         .columns()
                         .iter()
                         .skip(right_columns_length)
+                        .take(left_columns_length)

Review Comment:
   I don't think we should add it as we can lose columns or hide bugs if we the rest of the columns are not left



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Fix: Align sort_merge_join filter output with join schema to fix right-anti panic [datafusion]

Posted by "kumarUjjawal (via GitHub)" <gi...@apache.org>.
kumarUjjawal commented on PR #18800:
URL: https://github.com/apache/datafusion/pull/18800#issuecomment-3547799970

   hmm, why is the test failing? 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org