@@ -127,7 +127,8 @@ impl VariantSchema {
127
127
| DataType :: Utf8View
128
128
| DataType :: BinaryView
129
129
| DataType :: ListView ( _)
130
- | DataType :: Struct ( _) => { }
130
+ | DataType :: Struct ( _)
131
+ | DataType :: Dictionary ( _, _) => { }
131
132
foreign => {
132
133
return Err ( ArrowError :: NotYetImplemented ( format ! (
133
134
"Unsupported VariantArray 'typed_value' field, got {foreign}"
@@ -146,10 +147,35 @@ impl VariantSchema {
146
147
}
147
148
( Some ( value_field) , None ) => Ok ( ValueSchema :: Value ( value_field. 0 ) ) ,
148
149
( None , Some ( shredded_field) ) => Ok ( ValueSchema :: ShreddedValue ( shredded_field. 0 ) ) ,
149
- ( Some ( _value_field) , Some ( _shredded_field) ) => {
150
- todo ! ( "how does a shredded value look like?" ) ;
151
- // ideally here, i would unpack the shredded_field
152
- // and recursively call validate_value_and_typed_value with inside_shredded_object set to true
150
+ ( Some ( ( value_idx, _) ) , Some ( ( shredded_value_idx, shredded_field) ) ) => {
151
+ match shredded_field. data_type ( ) {
152
+ DataType :: Struct ( fields) => {
153
+ let _ = Self :: validate_value_and_typed_value ( fields, false ) ?;
154
+
155
+ Ok ( ValueSchema :: PartiallyShredded {
156
+ value_idx,
157
+ shredded_value_idx,
158
+ } )
159
+ }
160
+ DataType :: Dictionary ( _key, shredded_schema) => {
161
+ if let DataType :: Struct ( fields) = shredded_schema. as_ref ( ) {
162
+ let _ = Self :: validate_value_and_typed_value ( fields, true ) ?;
163
+
164
+ Ok ( ValueSchema :: PartiallyShredded {
165
+ value_idx,
166
+ shredded_value_idx,
167
+ } )
168
+ } else {
169
+ Err ( ArrowError :: InvalidArgumentError (
170
+ "Invalid VariantArray: shredded fields must be of struct or list types" . to_string ( ) ,
171
+ ) )
172
+ }
173
+ }
174
+ _ => Err ( ArrowError :: InvalidArgumentError (
175
+ "Invalid VariantArray: shredded fields must be of struct or list types"
176
+ . to_string ( ) ,
177
+ ) ) ,
178
+ }
153
179
}
154
180
}
155
181
}
0 commit comments