Skip to content

Commit c0a69a7

Browse files
authored
Fix expr partial ord test (#8908)
* Fix expr partial ord test * Add comment * Resolve linter error
1 parent 97441cc commit c0a69a7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

datafusion/expr/src/expr.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,10 +1869,14 @@ mod test {
18691869
let exp2 = col("a") + lit(2);
18701870
let exp3 = !(col("a") + lit(2));
18711871

1872-
assert!(exp1 < exp2);
1873-
assert!(exp2 > exp1);
1874-
assert!(exp2 > exp3);
1875-
assert!(exp3 < exp2);
1872+
// Since comparisons are done using hash value of the expression
1873+
// expr < expr2 may return false, or true. There is no guaranteed result.
1874+
// The only guarantee is "<" operator should have the opposite result of ">=" operator
1875+
let greater_or_equal = exp1 >= exp2;
1876+
assert_eq!(exp1 < exp2, !greater_or_equal);
1877+
1878+
let greater_or_equal = exp3 >= exp2;
1879+
assert_eq!(exp3 < exp2, !greater_or_equal);
18761880
}
18771881

18781882
#[test]

0 commit comments

Comments
 (0)