Skip to content

Commit

Permalink
fix: Allow search_sorted on boolean series (#18387)
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp authored Aug 27, 2024
1 parent 6269126 commit 950e4c3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/polars-ops/src/series/ops/search_sorted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ pub fn search_sorted(
let idx = binary_search_ca(&ca, search_values.iter(), side, descending);
Ok(IdxCa::new_vec(s.name(), idx))
},
DataType::Boolean => {
let ca = s.bool().unwrap();
let search_values = search_values.bool()?;

let mut none_pos = None;
let mut false_pos = None;
let mut true_pos = None;
let idxs = search_values
.iter()
.map(|v| {
let cache = match v {
None => &mut none_pos,
Some(false) => &mut false_pos,
Some(true) => &mut true_pos,
};
*cache.get_or_insert_with(|| {
binary_search_ca(ca, [v].into_iter(), side, descending)[0]
})
})
.collect();
Ok(IdxCa::new_vec(s.name(), idxs))
},
DataType::Binary => {
let ca = s.binary().unwrap();

Expand Down

0 comments on commit 950e4c3

Please sign in to comment.