Skip to content

Commit b026413

Browse files
committed
stuff
Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
1 parent 2567194 commit b026413

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • vortex-array/src/arrays/primitive/compute

vortex-array/src/arrays/primitive/compute/cast.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use vortex_buffer::Buffer;
55
use vortex_buffer::BufferMut;
66
use vortex_error::VortexResult;
7+
use vortex_error::vortex_bail;
78
use vortex_error::vortex_err;
89
use vortex_mask::AllOr;
910
use vortex_mask::Mask;
@@ -60,9 +61,12 @@ impl CastKernel for Primitive {
6061
&& array.ptype().byte_width() == new_ptype.byte_width()
6162
{
6263
if !values_fit_in(array, new_ptype) {
63-
return Ok(None);
64+
vortex_bail!(
65+
Compute: "Cannot cast {} to {} — values exceed target range",
66+
array.ptype(),
67+
new_ptype,
68+
);
6469
}
65-
6670
// SAFETY: both types are integers with the same size and alignment, and
6771
// min/max confirm all valid values are representable in the target type.
6872
return Ok(Some(unsafe {
@@ -210,7 +214,7 @@ mod test {
210214
.and_then(|a| a.to_canonical().map(|c| c.into_array()))
211215
.unwrap_err();
212216
assert!(matches!(error, VortexError::Compute(..)));
213-
assert!(error.to_string().contains("Failed to cast -1 to U32"));
217+
assert!(error.to_string().contains("values exceed target range"));
214218
}
215219

216220
#[test]

0 commit comments

Comments
 (0)