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

Minor: Fix bug in AND interval analysis tests (not code), and add more coverage #7886

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions datafusion/physical-expr/src/intervals/interval_aritmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,21 +1221,29 @@ mod tests {

#[test]
fn and_test() -> Result<()> {
// check that (lhs AND rhs) is equal to result
// ((lhs_lower, lhs_upper), (rhs_lower, rhs_upper), lower_result, upper_result))
let cases = vec![
(false, true, false, false, false, false),
(false, false, false, true, false, false),
(false, true, false, true, false, true),
(false, true, true, true, false, true),
(false, false, false, false, false, false),
(true, true, true, true, true, true),
// Note there are only three valid boolean intervals: [false, false], [false, true] and [true, true],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the three missing cases and reordered the cases so it was easier to see what is covered and what was not.

((false, false), (false, false), (false, false)),
((false, false), (false, true), (false, false)),
((false, false), (true, true), (false, false)),
((false, true), (false, false), (false, false)),
((false, true), (false, true), (false, true)),
((false, true), (true, true), (false, true)),
((true, true), (false, false), (false, false)),
((true, true), (false, true), (false, true)),
((true, true), (true, true), (true, true)),
];

for case in cases {
assert_eq!(
open_open(Some(case.0), Some(case.1))
.and(open_open(Some(case.2), Some(case.3)))?,
open_open(Some(case.4), Some(case.5))
);
let (lhs, rhs, expected) = case;
println!("case: {:?}", case);
let lhs = closed_closed(Some(lhs.0), Some(lhs.1));
let rhs = closed_closed(Some(rhs.0), Some(rhs.1));
let expected = closed_closed(Some(expected.0), Some(expected.1));
println!("lhs: {:?}, rhs: {:?}, expected: {:?}", lhs, rhs, expected);
assert_eq!(lhs.and(rhs)?, expected,);
}
Ok(())
}
Expand Down
Loading