@@ -9,13 +9,15 @@ use std::ops::Not;
99use prost:: Message ;
1010use vortex_compute:: mask:: MaskValidity ;
1111use vortex_dtype:: { DType , FieldName , FieldPath , Nullability } ;
12- use vortex_error:: { VortexResult , vortex_bail, vortex_err} ;
12+ use vortex_error:: { VortexExpect , VortexResult , vortex_bail, vortex_err} ;
1313use vortex_proto:: expr as pb;
1414use vortex_vector:: { Vector , VectorOps } ;
1515
1616use crate :: compute:: mask;
1717use crate :: expr:: exprs:: root:: root;
18- use crate :: expr:: { ChildName , ExprId , Expression , ExpressionView , StatsCatalog , VTable , VTableExt } ;
18+ use crate :: expr:: {
19+ ChildName , ExecutionArgs , ExprId , Expression , ExpressionView , StatsCatalog , VTable , VTableExt ,
20+ } ;
1921use crate :: stats:: Stat ;
2022use crate :: { ArrayRef , ToCanonical } ;
2123
@@ -98,29 +100,6 @@ impl VTable for GetItem {
98100 }
99101 }
100102
101- fn execute (
102- & self ,
103- expr : & ExpressionView < Self > ,
104- vector : & Vector ,
105- dtype : & DType ,
106- ) -> VortexResult < Vector > {
107- let child_dtype = expr. child ( 0 ) . return_dtype ( dtype) ?;
108- let struct_dtype = child_dtype
109- . as_struct_fields_opt ( )
110- . ok_or_else ( || vortex_err ! ( "Expected struct dtype for child of GetItem expression" ) ) ?;
111- let field_idx = struct_dtype
112- . find ( expr. data ( ) )
113- . ok_or_else ( || vortex_err ! ( "Field {} not found in struct dtype" , expr. data( ) ) ) ?;
114-
115- let struct_vector = expr. child ( 0 ) . execute ( vector, dtype) ?. into_struct ( ) ;
116-
117- // We must intersect the validity with that of the parent struct
118- let field = struct_vector. fields ( ) [ field_idx] . clone ( ) ;
119- let field = MaskValidity :: mask_validity ( field, struct_vector. validity ( ) ) ;
120-
121- Ok ( field)
122- }
123-
124103 fn stat_expression (
125104 & self ,
126105 expr : & ExpressionView < Self > ,
@@ -137,6 +116,27 @@ impl VTable for GetItem {
137116 // falsify expressions, but for now I'm preserving the existing buggy behavior.
138117 catalog. stats_ref ( & FieldPath :: from_name ( expr. data ( ) . clone ( ) ) , stat)
139118 }
119+
120+ fn execute ( & self , field_name : & FieldName , mut args : ExecutionArgs ) -> VortexResult < Vector > {
121+ let struct_dtype = args. dtypes [ 0 ]
122+ . as_struct_fields_opt ( )
123+ . ok_or_else ( || vortex_err ! ( "Expected struct dtype for child of GetItem expression" ) ) ?;
124+ let field_idx = struct_dtype
125+ . find ( field_name)
126+ . ok_or_else ( || vortex_err ! ( "Field {} not found in struct dtype" , field_name) ) ?;
127+
128+ let struct_vector = args
129+ . vectors
130+ . pop ( )
131+ . vortex_expect ( "missing input" )
132+ . into_struct ( ) ;
133+
134+ // We must intersect the validity with that of the parent struct
135+ let field = struct_vector. fields ( ) [ field_idx] . clone ( ) ;
136+ let field = MaskValidity :: mask_validity ( field, struct_vector. validity ( ) ) ;
137+
138+ Ok ( field)
139+ }
140140}
141141
142142/// Creates an expression that accesses a field from the root array.
0 commit comments