@@ -31,10 +31,15 @@ use crate::array::ArrayView;
3131use crate :: array:: VTable ;
3232use crate :: array:: ValidityChild ;
3333use crate :: array:: ValidityVTableFromChild ;
34+ use crate :: arrays:: Primitive ;
3435use crate :: arrays:: PrimitiveArray ;
3536use crate :: arrays:: patched:: PatchedArrayExt ;
3637use crate :: arrays:: patched:: PatchedData ;
38+ use crate :: arrays:: patched:: array:: INDICES_SLOT ;
39+ use crate :: arrays:: patched:: array:: INNER_SLOT ;
40+ use crate :: arrays:: patched:: array:: LANE_OFFSETS_SLOT ;
3741use crate :: arrays:: patched:: array:: SLOT_NAMES ;
42+ use crate :: arrays:: patched:: array:: VALUES_SLOT ;
3843use crate :: arrays:: patched:: compute:: rules:: PARENT_RULES ;
3944use crate :: arrays:: patched:: vtable:: kernels:: PARENT_KERNELS ;
4045use crate :: arrays:: primitive:: PrimitiveDataParts ;
@@ -45,6 +50,7 @@ use crate::dtype::DType;
4550use crate :: dtype:: NativePType ;
4651use crate :: dtype:: PType ;
4752use crate :: match_each_native_ptype;
53+ use crate :: require_child;
4854use crate :: serde:: ArrayChildren ;
4955use crate :: vtable;
5056
@@ -242,12 +248,18 @@ impl VTable for Patched {
242248 SLOT_NAMES [ idx] . to_string ( )
243249 }
244250
245- fn execute ( array : Array < Self > , ctx : & mut ExecutionCtx ) -> VortexResult < ExecutionResult > {
251+ fn execute ( array : Array < Self > , _ctx : & mut ExecutionCtx ) -> VortexResult < ExecutionResult > {
252+ let array = require_child ! ( array, array. base_array( ) , INNER_SLOT => Primitive ) ;
253+ let array = require_child ! ( array, array. lane_offsets( ) , LANE_OFFSETS_SLOT => Primitive ) ;
254+ let array = require_child ! ( array, array. patch_indices( ) , INDICES_SLOT => Primitive ) ;
255+ let array = require_child ! ( array, array. patch_values( ) , VALUES_SLOT => Primitive ) ;
256+
246257 let inner = array
247258 . base_array ( )
248259 . clone ( )
249- . execute :: < Canonical > ( ctx) ?
250- . into_primitive ( ) ;
260+ . try_downcast :: < Primitive > ( )
261+ . ok ( )
262+ . vortex_expect ( "base_array pre-canonicalized to Primitive" ) ;
251263
252264 let PrimitiveDataParts {
253265 buffer,
@@ -258,17 +270,21 @@ impl VTable for Patched {
258270 let lane_offsets = array
259271 . lane_offsets ( )
260272 . clone ( )
261- . execute :: < PrimitiveArray > ( ctx) ?;
273+ . try_downcast :: < Primitive > ( )
274+ . ok ( )
275+ . vortex_expect ( "lane_offsets pre-canonicalized to Primitive" ) ;
262276 let indices = array
263277 . patch_indices ( )
264278 . clone ( )
265- . execute :: < PrimitiveArray > ( ctx ) ? ;
266-
267- // TODO(aduffy): add support for non-primitive PatchedArray patches application (?)
279+ . try_downcast :: < Primitive > ( )
280+ . ok ( )
281+ . vortex_expect ( "patch_indices pre-canonicalized to Primitive" ) ;
268282 let values = array
269283 . patch_values ( )
270284 . clone ( )
271- . execute :: < PrimitiveArray > ( ctx) ?;
285+ . try_downcast :: < Primitive > ( )
286+ . ok ( )
287+ . vortex_expect ( "patch_values pre-canonicalized to Primitive" ) ;
272288
273289 let patched_values = match_each_native_ptype ! ( values. ptype( ) , |V | {
274290 let offset = array. offset( ) ;
0 commit comments