Skip to content

Commit

Permalink
[BUG]: between panic on unsupported types (#3150)
Browse files Browse the repository at this point in the history
  • Loading branch information
universalmind303 authored Oct 30, 2024
1 parent 701a011 commit eaf4d03
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/daft-core/src/series/ops/between.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common_error::DaftResult;
use common_error::{DaftError, DaftResult};

#[cfg(feature = "python")]
use crate::series::utils::python_fn::py_between_op_utilfn;
Expand All @@ -22,6 +22,7 @@ impl Series {
} else {
(self.clone(), lower.clone(), upper.clone())
};

if output_type == DataType::Boolean {
match comp_type {
#[cfg(feature = "python")]
Expand All @@ -30,15 +31,21 @@ impl Series {
.clone()
.into_series()),
DataType::Null => Ok(Self::full_null(self.name(), &DataType::Boolean, self.len())),
_ => with_match_numeric_daft_types!(comp_type, |$T| {
let casted_value = it_value.cast(&comp_type)?;
let casted_lower = it_lower.cast(&comp_type)?;
let casted_upper = it_upper.cast(&comp_type)?;
let value = casted_value.downcast::<<$T as DaftDataType>::ArrayType>()?;
let lower = casted_lower.downcast::<<$T as DaftDataType>::ArrayType>()?;
let upper = casted_upper.downcast::<<$T as DaftDataType>::ArrayType>()?;
Ok(value.between(lower, upper)?.into_series())
}),
ref v if v.is_numeric() => {
with_match_numeric_daft_types!(comp_type, |$T| {
let casted_value = it_value.cast(&comp_type)?;
let casted_lower = it_lower.cast(&comp_type)?;
let casted_upper = it_upper.cast(&comp_type)?;
let value = casted_value.downcast::<<$T as DaftDataType>::ArrayType>()?;
let lower = casted_lower.downcast::<<$T as DaftDataType>::ArrayType>()?;
let upper = casted_upper.downcast::<<$T as DaftDataType>::ArrayType>()?;
Ok(value.between(lower, upper)?.into_series())
})
}
other => Err(DaftError::ValueError(format!(
"Unsupported data type for between operation: {:?}",
other
))),
}
} else {
unreachable!()
Expand Down

0 comments on commit eaf4d03

Please sign in to comment.