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 bug while merging RecordBatch, add SortPreservingMerge fuzz tester #1678

Merged
merged 2 commits into from
Jan 27, 2022

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jan 25, 2022

Which issue does this PR close?

Fixes #1676

Includes the code from @yjshen alamb#4 in a separate commit ❤️

Rationale for this change

Despite pretty good testing in SortPreservingMerge there was at least one case that is not yet covered. This PR adds

What changes are included in this PR?

  1. A "fuzz" tester that tests merging various combinations of streams (broken into multiple batches, as well as various ranges)
  2. Includes the code from @yjshen skip empty batch while inserting alamb/datafusion#4 in a separate commit that fixes Regression: Merge assertion: 'assertion failed: i < self.len()' in array_primitive.rs while merging non overlapping streams #1676

Are there any user-facing changes?

Bug is fixed

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Jan 25, 2022
@alamb
Copy link
Contributor Author

alamb commented Jan 25, 2022

Marking as a draft as I still plan to add a few more cases to this tester (as I work on #1676 )

@alamb alamb changed the title Add SortPreservingMerge fuzz tester Fix bug while merging RecordBatch, Add SortPreservingMerge fuzz tester Jan 26, 2022
@@ -410,40 +410,53 @@ impl SortPreservingMergeStream {
// Cursor is not finished - don't need a new RecordBatch yet
return Poll::Ready(Ok(()));
}
let mut streams = self.streams.streams.lock().unwrap();
let mut empty_batch = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes to this file are easier to see if you use a whitespace blind diff:
https://github.com/apache/arrow-datafusion/pull/1678/files?w=1

}

#[tokio::test]
async fn test_merge_2_no_overlap() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test fails without the changes to datafusion/src/physical_plan/sorts/sort_preserving_merge.rs

@alamb alamb marked this pull request as ready for review January 26, 2022 15:59
@alamb alamb changed the title Fix bug while merging RecordBatch, Add SortPreservingMerge fuzz tester Fix bug while merging RecordBatch, add SortPreservingMerge fuzz tester Jan 26, 2022
Copy link
Member

@houqp houqp left a comment

Choose a reason for hiding this comment

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

LGTM

@houqp houqp added the bug Something isn't working label Jan 27, 2022
@alamb alamb merged commit 2266474 into apache:master Jan 27, 2022
@alamb alamb deleted the alamb/merge_fuzz branch January 27, 2022 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working datafusion Changes in the datafusion crate
Projects
None yet
3 participants