Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SortMergeJoin with join filter filtering all rows out #10495

Merged
merged 3 commits into from
May 14, 2024

Conversation

viirya
Copy link
Member

@viirya viirya commented May 14, 2024

Which issue does this PR close?

Closes #10491.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the core Core DataFusion crate label May 14, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @viirya -- looks good to me

let sql = "set datafusion.execution.batch_size = 1";
let _ = ctx.sql(sql).await?.collect().await?;

let sql = "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any reason this isn't a slt test (in https://github.com/apache/datafusion/blob/main/datafusion/sqllogictest/test_files/sort_merge_join.slt)? Looks like it would work just fine

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I simply copy the reproducer from the issue. Let me move it to sort_merge_join.slt.

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @viirya for quick turnaround,I agree lets please move the test to slt file

@@ -1323,7 +1323,9 @@ impl SMJStream {
// If join filter exists, `self.output_size` is not accurate as we don't know the exact
// number of rows in the output record batch. If streamed row joined with buffered rows,
// once join filter is applied, the number of output rows may be more than 1.
if record_batch.num_rows() > self.output_size {
// If `record_batch` is empty, we should reset `self.output_size` to 0. It could be happened
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) and removed core Core DataFusion crate labels May 14, 2024
@comphead comphead merged commit 1d4b808 into apache:main May 14, 2024
23 checks passed
@viirya
Copy link
Member Author

viirya commented May 14, 2024

Thanks @alamb @comphead

@viirya viirya deleted the fix_smj_filter_empty branch May 14, 2024 18:02
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
* Fix SortMergeJoin with join filter filtering all rows out

* Move test

* Update datafusion/sqllogictest/test_files/sort_merge_join.slt

---------

Co-authored-by: Oleks V <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SortMergeJoin: The query stuck when join filter is set and more matched rows than batch size
3 participants