You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "tglanz (via GitHub)" <gi...@apache.org> on 2025/11/17 14:26:37 UTC
[PR] fix: SMJ Right take correct columns [datafusion]
tglanz opened a new pull request, #18772:
URL: https://github.com/apache/datafusion/pull/18772
## 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.
-->
## 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.
-->
## 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)?
-->
## 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: SMJ Right take correct columns [datafusion]
Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton commented on code in PR #18772:
URL: https://github.com/apache/datafusion/pull/18772#discussion_r2535417315
##########
datafusion/physical-plan/src/joins/sort_merge_join/stream.rs:
##########
Review Comment:
this should also be changed to:
```suggestion
.take(left_columns_length)
```
--
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: Pick correct columns in Sort Merge Equijoin [datafusion]
Posted by "tglanz (via GitHub)" <gi...@apache.org>.
tglanz commented on PR #18772:
URL: https://github.com/apache/datafusion/pull/18772#issuecomment-3548565193
Fuzz tests are taken from @rluvaton 's #18788 , excluding those this PR doesn't fix:
```
fuzz_cases::join_fuzz::test_right_anti_join_1k_binary_filtered
fuzz_cases::join_fuzz::test_right_anti_join_1k_filtered
fuzz_cases::join_fuzz::test_right_semi_join_1k_filtered
```
--
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: SMJ Right take correct columns [datafusion]
Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton commented on PR #18772:
URL: https://github.com/apache/datafusion/pull/18772#issuecomment-3543722267
I was able to reproduce the bug when changing the sort_merge_join.slt to have 3 columns in `t2` rather than 2 like in `t1` (below is the diff I changed in the `sort_merge_join.slt` file).
Can you please update the description and update/add tests (I would update the sort_merge_join.slt like in the diff below to make sure all tests are testing that. make sure to add a comment on why 3 columns and t1 2).
<details>
<summary>Updated the slt file to reproduce the error</summary>
```diff
diff --git a/datafusion/sqllogictest/test_files/sort_merge_join.slt b/datafusion/sqllogictest/test_files/sort_merge_join.slt
--- a/datafusion/sqllogictest/test_files/sort_merge_join.slt (revision f3980641660997345af6061dc3b34f365020bd07)
+++ b/datafusion/sqllogictest/test_files/sort_merge_join.slt (date 1763411346050)
@@ -26,7 +26,7 @@
CREATE TABLE t1(a text, b int) AS VALUES ('Alice', 50), ('Alice', 100), ('Bob', 1);
statement ok
-CREATE TABLE t2(a text, b int) AS VALUES ('Alice', 2), ('Alice', 1);
+CREATE TABLE t2(a text, b int, c int) AS VALUES ('Alice', 2, 77), ('Alice', 1, 66);
# inner join query plan with join filter
query TT
@@ -64,83 +64,83 @@
----
# left join without join filter
-query TITI rowsort
+query TITII rowsort
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a
----
-Alice 100 Alice 1
-Alice 100 Alice 2
-Alice 50 Alice 1
-Alice 50 Alice 2
-Bob 1 NULL NULL
+Alice 100 Alice 1 66
+Alice 100 Alice 2 77
+Alice 50 Alice 1 66
+Alice 50 Alice 2 77
+Bob 1 NULL NULL NULL
# left join with join filter
-query TITI rowsort
+query TITII rowsort
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a AND t2.b * 50 <= t1.b
----
-Alice 100 Alice 1
-Alice 100 Alice 2
-Alice 50 Alice 1
-Bob 1 NULL NULL
+Alice 100 Alice 1 66
+Alice 100 Alice 2 77
+Alice 50 Alice 1 66
+Bob 1 NULL NULL NULL
-query TITI rowsort
+query TITII rowsort
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a AND t2.b < t1.b
----
-Alice 100 Alice 1
-Alice 100 Alice 2
-Alice 50 Alice 1
-Alice 50 Alice 2
-Bob 1 NULL NULL
+Alice 100 Alice 1 66
+Alice 100 Alice 2 77
+Alice 50 Alice 1 66
+Alice 50 Alice 2 77
+Bob 1 NULL NULL NULL
# right join without join filter
-query TITI rowsort
+query TITII rowsort
SELECT * FROM t1 RIGHT JOIN t2 ON t1.a = t2.a
----
-Alice 100 Alice 1
-Alice 100 Alice 2
-Alice 50 Alice 1
-Alice 50 Alice 2
+Alice 100 Alice 1 66
+Alice 100 Alice 2 77
+Alice 50 Alice 1 66
+Alice 50 Alice 2 77
# right join with join filter
-query TITI rowsort
+query TITII rowsort
SELECT * FROM t1 RIGHT JOIN t2 ON t1.a = t2.a AND t2.b * 50 <= t1.b
----
-Alice 100 Alice 1
-Alice 100 Alice 2
-Alice 50 Alice 1
+Alice 100 Alice 1 66
+Alice 100 Alice 2 77
+Alice 50 Alice 1 66
-query TITI rowsort
+query TITII rowsort
SELECT * FROM t1 RIGHT JOIN t2 ON t1.a = t2.a AND t1.b > t2.b
----
-Alice 100 Alice 1
-Alice 100 Alice 2
-Alice 50 Alice 1
-Alice 50 Alice 2
+Alice 100 Alice 1 66
+Alice 100 Alice 2 77
+Alice 50 Alice 1 66
+Alice 50 Alice 2 77
# full join without join filter
-query TITI rowsort
+query TITII rowsort
SELECT * FROM t1 FULL JOIN t2 ON t1.a = t2.a
----
-Alice 100 Alice 1
-Alice 100 Alice 2
-Alice 50 Alice 1
-Alice 50 Alice 2
-Bob 1 NULL NULL
+Alice 100 Alice 1 66
+Alice 100 Alice 2 77
+Alice 50 Alice 1 66
+Alice 50 Alice 2 77
+Bob 1 NULL NULL NULL
-query TITI rowsort
+query TITII rowsort
SELECT * FROM t1 FULL JOIN t2 ON t1.a = t2.a AND t2.b * 50 > t1.b
----
-Alice 100 NULL NULL
-Alice 50 Alice 2
-Bob 1 NULL NULL
-NULL NULL Alice 1
+Alice 100 NULL NULL NULL
+Alice 50 Alice 2 77
+Bob 1 NULL NULL NULL
+NULL NULL Alice 1 66
-query TITI rowsort
+query TITII rowsort
SELECT * FROM t1 FULL JOIN t2 ON t1.a = t2.a AND t1.b > t2.b + 50
----
-Alice 100 Alice 1
-Alice 100 Alice 2
-Alice 50 NULL NULL
-Bob 1 NULL NULL
+Alice 100 Alice 1 66
+Alice 100 Alice 2 77
+Alice 50 NULL NULL NULL
+Bob 1 NULL NULL NULL
statement ok
DROP TABLE t1;
```
</details>
--
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: SMJ Right take correct columns [datafusion]
Posted by "tglanz (via GitHub)" <gi...@apache.org>.
tglanz commented on PR #18772:
URL: https://github.com/apache/datafusion/pull/18772#issuecomment-3543888887
Thanks @rluvaton, Sure
--
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: SMJ Right take correct columns [datafusion]
Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton commented on code in PR #18772:
URL: https://github.com/apache/datafusion/pull/18772#discussion_r2535417315
##########
datafusion/physical-plan/src/joins/sort_merge_join/stream.rs:
##########
Review Comment:
I think this should also be changed to:
```suggestion
.take(left_columns_length)
```
--
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: Pick correct columns in Sort Merge Equijoin [datafusion]
Posted by "rluvaton (via GitHub)" <gi...@apache.org>.
rluvaton merged PR #18772:
URL: https://github.com/apache/datafusion/pull/18772
--
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