@@ -47,6 +47,14 @@ impl ReorderIndex {
47
47
}
48
48
}
49
49
50
+ fn set_index ( & mut self , target_index : usize ) {
51
+ match self {
52
+ ReorderIndex :: Child { ref mut index, .. } => * index = target_index,
53
+ ReorderIndex :: Index { ref mut index } => * index = target_index,
54
+ ReorderIndex :: Null { ref mut index, .. } => * index = target_index,
55
+ }
56
+ }
57
+
50
58
/// check if this indexing is ordered. an `Index` variant is ordered by definition. a `Null`
51
59
/// variant is not because if we have a `Null` variant we need to do work in
52
60
/// reorder_struct_array to insert the null col
@@ -153,37 +161,19 @@ fn get_indices(
153
161
// see comment above in struct match arm
154
162
parquet_offset += parquet_advance - 1 ;
155
163
found_fields. insert ( requested_field. name ( ) ) ;
156
- // we have to recurse to find the type, but for reordering a list we
157
- // only need a child reordering if the inner type is a struct
158
- if let ArrowDataType :: Struct ( _) = list_field. data_type ( ) {
159
- if children. len ( ) != 1 {
160
- return Err (
161
- Error :: generic (
162
- "List call should not have generated more than one reorder index"
163
- )
164
- ) ;
165
- }
166
- // safety, checked that we have 1 element
167
- let mut children = children. into_iter ( ) . next ( ) . unwrap ( ) ;
168
- // the index is wrong though, as it's the index from the inner
169
- // schema. Adjust it to be our index
170
- if let ReorderIndex :: Child {
171
- index : ref mut child_index,
172
- ..
173
- } = children
174
- {
175
- * child_index = index;
176
- } else {
177
- return Err (
178
- Error :: generic (
179
- "List call should have returned a ReorderIndex::Child variant"
180
- )
181
- ) ;
182
- }
183
- reorder_indices. push ( children) ;
184
- } else {
185
- reorder_indices. push ( ReorderIndex :: Index { index } ) ;
164
+ if children. len ( ) != 1 {
165
+ return Err (
166
+ Error :: generic (
167
+ "List call should not have generated more than one reorder index"
168
+ )
169
+ ) ;
186
170
}
171
+ // safety, checked that we have 1 element
172
+ let mut children = children. into_iter ( ) . next ( ) . unwrap ( ) ;
173
+ // the index is wrong, as it's the index from the inner schema. Adjust
174
+ // it to be our index
175
+ children. set_index ( index) ;
176
+ reorder_indices. push ( children) ;
187
177
}
188
178
_ => {
189
179
return Err ( Error :: unexpected_column_type ( list_field. name ( ) ) ) ;
0 commit comments