File tree Expand file tree Collapse file tree
vortex-array/src/arrays/primitive/compute Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44use vortex_buffer:: Buffer ;
55use vortex_buffer:: BufferMut ;
66use vortex_error:: VortexResult ;
7+ use vortex_error:: vortex_bail;
78use vortex_error:: vortex_err;
89use vortex_mask:: AllOr ;
910use 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]
You can’t perform that action at this time.
0 commit comments