@@ -14,12 +14,7 @@ use vortex_session::VortexSession;
1414
1515use crate :: ArrayRef ;
1616use crate :: ExecutionCtx ;
17- use crate :: arrays:: Filter ;
18- use crate :: arrays:: Slice ;
1917use crate :: arrays:: Variant ;
20- use crate :: arrays:: filter:: FilterArrayExt ;
21- use crate :: arrays:: scalar_fn:: ScalarFnFactoryExt ;
22- use crate :: arrays:: slice:: SliceArrayExt ;
2318use crate :: arrays:: variant:: VariantArrayExt ;
2419use crate :: dtype:: DType ;
2520use crate :: dtype:: Nullability ;
@@ -46,8 +41,11 @@ pub use path::VariantPathElement;
4641/// requested path may not exist in every row.
4742///
4843/// Execution is handled by variant encodings (e.g. `ParquetVariantArray`) via `execute_parent`.
49- /// The canonical `VariantArray` does not support direct execution; a `reduce` rule unwraps
50- /// the `VariantArray` wrapper to expose the underlying encoding.
44+ /// The canonical `VariantArray` does not support direct execution, so `VariantGet` keeps a small
45+ /// `reduce` rule that unwraps a direct `VariantArray` child to expose the underlying encoding.
46+ /// Wrapper arrays such as `Slice` and `Filter` forward `VariantGet` from their own
47+ /// `execute_parent` hooks so the expression can still reach the underlying variant encoding
48+ /// without teaching `VariantGet` about wrapper-specific array shapes.
5149#[ derive( Clone ) ]
5250pub struct VariantGet ;
5351
@@ -222,12 +220,7 @@ impl ScalarFnVTable for VariantGet {
222220 args : & dyn ExecutionArgs ,
223221 ctx : & mut ExecutionCtx ,
224222 ) -> VortexResult < ArrayRef > {
225- let input = args. get ( 0 ) ?;
226-
227- if let Some ( rewritten) = rewrite_wrapped_variant_input ( input, options, ctx) ? {
228- return Ok ( rewritten) ;
229- }
230-
223+ let _ = ( options, args, ctx) ;
231224 vortex_bail ! ( "variant_get cannot be executed directly" )
232225 }
233226
@@ -262,48 +255,6 @@ impl ScalarFnVTable for VariantGet {
262255 }
263256}
264257
265- fn rewrite_wrapped_variant_input (
266- input : ArrayRef ,
267- options : & VariantGetOptions ,
268- ctx : & mut ExecutionCtx ,
269- ) -> VortexResult < Option < ArrayRef > > {
270- if let Some ( slice) = input. as_opt :: < Slice > ( ) {
271- let Some ( inner) = unwrap_variant_input ( slice. child ( ) ) else {
272- return Ok ( None ) ;
273- } ;
274- let sliced = inner
275- . slice ( slice. slice_range ( ) . clone ( ) ) ?
276- . execute :: < ArrayRef > ( ctx) ?;
277- return VariantGet
278- . try_new_array ( input. len ( ) , options. clone ( ) , [ sliced] ) ?
279- . execute :: < ArrayRef > ( ctx)
280- . map ( Some ) ;
281- }
282-
283- if let Some ( filter) = input. as_opt :: < Filter > ( ) {
284- let Some ( inner) = unwrap_variant_input ( filter. child ( ) ) else {
285- return Ok ( None ) ;
286- } ;
287- let filtered = inner
288- . filter ( filter. filter_mask ( ) . clone ( ) ) ?
289- . execute :: < ArrayRef > ( ctx) ?;
290- return VariantGet
291- . try_new_array ( input. len ( ) , options. clone ( ) , [ filtered] ) ?
292- . execute :: < ArrayRef > ( ctx)
293- . map ( Some ) ;
294- }
295-
296- Ok ( None )
297- }
298-
299- fn unwrap_variant_input ( input : & ArrayRef ) -> Option < ArrayRef > {
300- if let Some ( variant) = input. as_opt :: < Variant > ( ) {
301- return Some ( variant. child ( ) . clone ( ) ) ;
302- }
303-
304- matches ! ( input. dtype( ) , DType :: Variant ( _) ) . then ( || input. clone ( ) )
305- }
306-
307258#[ cfg( test) ]
308259mod tests {
309260 use vortex_session:: VortexSession ;
0 commit comments