@@ -11,7 +11,11 @@ use crate::compute::{CastKernel, CastKernelAdapter, cast};
11
11
use crate :: { ArrayRef , IntoArray , register_kernel} ;
12
12
13
13
impl CastKernel for ExtensionVTable {
14
- fn cast ( & self , array : & ExtensionArray , dtype : & DType ) -> vortex_error:: VortexResult < ArrayRef > {
14
+ fn cast (
15
+ & self ,
16
+ array : & ExtensionArray ,
17
+ dtype : & DType ,
18
+ ) -> vortex_error:: VortexResult < Option < ArrayRef > > {
15
19
if !array. dtype ( ) . eq_ignore_nullability ( dtype) {
16
20
vortex_bail ! ( "Cannot cast {} to {}" , array. dtype( ) , dtype) ;
17
21
}
@@ -39,15 +43,23 @@ impl CastKernel for ExtensionVTable {
39
43
"invalid cast from nullable to non-nullable, since source array actually contains nulls"
40
44
) ;
41
45
} ;
42
- let new_storage = cast ( storage_array. as_ref ( ) , & new_storage_dtype) ?;
46
+ let new_storage = match cast ( storage_array. as_ref ( ) , & new_storage_dtype) {
47
+ Ok ( arr) => arr,
48
+ Err ( e) => {
49
+ log:: warn!( "Failed to cast storage array: {e}" ) ;
50
+ return Ok ( None ) ;
51
+ }
52
+ } ;
43
53
44
54
let new_ext_dtype = ExtDType :: new (
45
55
ext_dtype. id ( ) . clone ( ) ,
46
56
Arc :: new ( new_storage_dtype. clone ( ) ) ,
47
57
ext_dtype. metadata ( ) . cloned ( ) ,
48
58
) ;
49
59
50
- Ok ( ExtensionArray :: new ( new_ext_dtype. into ( ) , new_storage) . into_array ( ) )
60
+ Ok ( Some (
61
+ ExtensionArray :: new ( new_ext_dtype. into ( ) , new_storage) . into_array ( ) ,
62
+ ) )
51
63
}
52
64
}
53
65
0 commit comments