Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
danking committed Jan 15, 2025
1 parent 33a69b4 commit 950f154
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vortex-scalar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ impl Scalar {
}

pub fn cast(&self, dtype: &DType) -> VortexResult<Self> {
if self.is_null() && !dtype.is_nullable() {
vortex_bail!("Can't cast null scalar to non-nullable type")
}

if self.is_null() && dtype.is_nullable() {
return Ok(Scalar::new(dtype.clone(), self.value.clone()));
if self.is_null() {
if dtype.is_nullable() {
return Ok(Scalar::new(dtype.clone(), self.value.clone()));
} else {
vortex_bail!("Can't cast null scalar to non-nullable type")
}
}

if self.dtype().eq_ignore_nullability(dtype) {
Expand Down

0 comments on commit 950f154

Please sign in to comment.