File tree Expand file tree Collapse file tree
scalar_fn/fns/variant_get Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ pub trait VariantArrayExt: TypedArrayRef<Variant> {
4141 }
4242
4343 /// Returns the optional row-aligned typed shredded tree for selected variant paths.
44+ /// This functions returns `Some` only if the array was canonicalized and the shredded data
45+ /// was pulled out of the underlying variant storage.
4446 fn shredded ( & self ) -> Option < & ArrayRef > {
4547 self . as_ref ( ) . slots ( ) [ SHREDDED_SLOT ] . as_ref ( )
4648 }
Original file line number Diff line number Diff line change @@ -134,6 +134,9 @@ impl ExecuteParentKernel<Variant> for VariantGetKernel {
134134
135135 // Null typed rows are not necessarily missing from the logical variant value;
136136 // fill those rows from core storage and keep valid typed rows unchanged.
137+ // TODO: we are computing the entire fallback array here but only take indices where
138+ // typed_mask is false, so we can narrow the core_storage to only the false
139+ // indices and compute from there then zip
137140 let fallback = make_fallback ( ctx) ?;
138141 typed_mask
139142 . into_array ( )
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ impl OperationsVTable<Variant> for Variant {
1818 ctx : & mut ExecutionCtx ,
1919 ) -> VortexResult < Scalar > {
2020 let core_storage = array. core_storage ( ) ;
21- if ! core_storage. is_valid ( index, ctx) ? {
21+ if core_storage. is_invalid ( index, ctx) ? {
2222 return Ok ( Scalar :: null ( array. dtype ( ) . clone ( ) ) ) ;
2323 }
2424
@@ -27,6 +27,7 @@ impl OperationsVTable<Variant> for Variant {
2727 } ;
2828
2929 let typed = shredded. execute_scalar ( index, ctx) ?;
30+ // If the shredded value is null OR we shredded an object we want to merge back together.
3031 let fallback = ( typed. is_null ( ) || typed. dtype ( ) . is_struct ( ) )
3132 . then ( || core_storage. execute_scalar ( index, ctx) )
3233 . transpose ( ) ?;
Original file line number Diff line number Diff line change @@ -685,6 +685,8 @@ impl Executable for CanonicalValidity {
685685/// callers should prefer an execution target that's suitable for their use case instead of this one.
686686pub struct RecursiveCanonical ( pub Canonical ) ;
687687
688+ // TODO: Currently only used for Variant, in the future
689+ // can probably be used for more canonical types like Struct.
688690fn recursively_canonicalize_slots (
689691 array : & ArrayRef ,
690692 ctx : & mut ExecutionCtx ,
Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ impl ScalarFnVTable for VariantGet {
119119 "VariantGet input must be Variant, found {input_dtype}"
120120 ) ;
121121
122+ // Missing paths, traversal mismatches, and cast failures all produce nulls.
122123 Ok ( options
123124 . dtype ( )
124125 . map_or ( DType :: Variant ( Nullability :: Nullable ) , DType :: as_nullable) )
@@ -131,6 +132,7 @@ impl ScalarFnVTable for VariantGet {
131132 ctx : & mut ExecutionCtx ,
132133 ) -> VortexResult < ArrayRef > {
133134 let input = args. get ( 0 ) ?;
135+ // Missing paths, traversal mismatches, and cast failures all produce nulls.
134136 let dtype = options
135137 . dtype ( )
136138 . map_or ( DType :: Variant ( Nullability :: Nullable ) , DType :: as_nullable) ;
You can’t perform that action at this time.
0 commit comments