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!: Fix NaN ordering to make NaNs compare greater than any other float, and equal to themselves #12721

Merged
merged 35 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
434a7d7
move TotalOrd to polars-utils
orlp Oct 16, 2023
a309b3b
add polars-compute
orlp Oct 16, 2023
eaed1e7
wip
orlp Oct 17, 2023
c1912d6
remove nans_compare_equal
orlp Nov 23, 2023
913a4f1
remove float comparison exceptions
orlp Nov 23, 2023
d37d9c0
mostly fix broadcasting comparisons
orlp Nov 24, 2023
01fb1bb
remove inconsistent null equality optimization
orlp Nov 27, 2023
33f09b9
add warning to always-null comparisons
orlp Nov 27, 2023
3c5e101
fmt
orlp Nov 27, 2023
14e43eb
fix warnings in tests
orlp Nov 27, 2023
5c4a943
fix _missing comparison ops
orlp Nov 27, 2023
467b7fc
clippy
orlp Nov 27, 2023
d7fb115
remove not_equal_and_validity
orlp Nov 28, 2023
5354923
add new string comparison kernels
orlp Nov 28, 2023
da58d14
define gt/ge in terms of lt/le
orlp Nov 28, 2023
74f4e3f
add _missing kernels
orlp Nov 28, 2023
b6359c4
add array support to comparison kernels
orlp Nov 28, 2023
a50997d
fmt/clippy
orlp Nov 28, 2023
5a2c321
add boolean comparison kernels
orlp Nov 29, 2023
06b9426
expand comparison tests
orlp Nov 29, 2023
80a12d9
fix test
orlp Nov 29, 2023
0b93380
user new string broadcast comparison kernels
orlp Nov 29, 2023
ed030c3
remove old comparison kernels
orlp Nov 29, 2023
ba409a4
clippy
orlp Nov 29, 2023
ea99583
fix bad/outdated tests
orlp Nov 29, 2023
9013166
fix trait bounds
orlp Nov 29, 2023
3c63fec
fix conditional import
orlp Nov 29, 2023
cb4da95
fix another bad test
orlp Nov 29, 2023
1bd4957
fix failing doctest
orlp Nov 29, 2023
ba8c5e2
address review comments
orlp Nov 30, 2023
d58dc7c
fix mypy
orlp Nov 30, 2023
e2e8b85
fix incorrect bitcount
orlp Nov 30, 2023
3b00eb1
add missing inline
orlp Nov 30, 2023
733c634
add missing comment
orlp Nov 30, 2023
7a340e4
fmt
orlp Nov 30, 2023
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
Prev Previous commit
Next Next commit
remove inconsistent null equality optimization
  • Loading branch information
orlp committed Nov 27, 2023
commit 01fb1bb5c5c9ff07115ea5ead69c2e797221dcc5
2 changes: 1 addition & 1 deletion crates/polars-arrow/src/types/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ impl TotalEq for f16 {
}

impl TotalOrd for f16 {
fn tot_cmp(&self, other: &Self) -> std::cmp::Ordering {
fn tot_cmp(&self, _other: &Self) -> std::cmp::Ordering {
unimplemented!()
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-core/src/chunked_array/comparison/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ where
debug_assert!(self.dtype() == other.dtype());
let ca_other = &*(ca_other as *const ChunkedArray<T>);
// Should be get and not get_unchecked, because there could be nulls
self.get(idx_self) == ca_other.get(idx_other)
self.get(idx_self).tot_eq(&ca_other.get(idx_other))
}
}

Expand Down
47 changes: 2 additions & 45 deletions crates/polars-plan/src/logical_plan/optimizer/simplify_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ impl OptimizationRule for SimplifyExprRule {
let right_aexpr = expr_arena.get(*right);

// lit(left) + lit(right) => lit(left + right)
use Operator::*;
#[allow(clippy::manual_map)]
let out = match op {
Plus => {
Expand Down Expand Up @@ -524,51 +525,7 @@ impl OptimizationRule for SimplifyExprRule {
return Ok(out);
}

// Null propagation.
let left_is_null = matches!(left_aexpr, AExpr::Literal(LiteralValue::Null));
let right_is_null = matches!(right_aexpr, AExpr::Literal(LiteralValue::Null));
use Operator::*;
match (left_is_null, op, right_is_null) {
// all null operation null -> null
(true, _, true) => Some(AExpr::Literal(LiteralValue::Null)),
// null == column -> column.is_null()
(true, Eq, false) => Some(AExpr::Function {
input: vec![*right],
function: BooleanFunction::IsNull.into(),
options: FunctionOptions {
collect_groups: ApplyOptions::GroupWise,
..Default::default()
},
}),
// column == null -> column.is_null()
(false, Eq, true) => Some(AExpr::Function {
input: vec![*left],
function: BooleanFunction::IsNull.into(),
options: FunctionOptions {
collect_groups: ApplyOptions::GroupWise,
..Default::default()
},
}),
// null != column -> column.is_not_null()
(true, NotEq, false) => Some(AExpr::Function {
input: vec![*right],
function: BooleanFunction::IsNotNull.into(),
options: FunctionOptions {
collect_groups: ApplyOptions::GroupWise,
..Default::default()
},
}),
// column != null -> column.is_not_null()
(false, NotEq, true) => Some(AExpr::Function {
input: vec![*left],
function: BooleanFunction::IsNotNull.into(),
options: FunctionOptions {
collect_groups: ApplyOptions::GroupWise,
..Default::default()
},
}),
_ => None,
}
None
},
// sort().reverse() -> sort(reverse)
// sort_by().reverse() -> sort_by(reverse)
Expand Down