@@ -21,6 +21,7 @@ use vortex_array::dtype::FieldMask;
2121use vortex_array:: expr:: Expression ;
2222use vortex_error:: VortexExpect ;
2323use vortex_error:: VortexResult ;
24+ use vortex_error:: vortex_ensure;
2425use vortex_error:: vortex_panic;
2526use vortex_mask:: Mask ;
2627use vortex_session:: VortexSession ;
@@ -290,9 +291,11 @@ impl LayoutReader for ChunkedReader {
290291 expr : & Expression ,
291292 mask : MaskFuture ,
292293 ) -> VortexResult < BoxFuture < ' static , VortexResult < ArrayRef > > > {
293- let dtype = expr. return_dtype ( self . dtype ( ) ) ?;
294294 if row_range. is_empty ( ) {
295- return Ok ( future:: ready ( Ok ( Canonical :: empty ( & dtype) . into_array ( ) ) ) . boxed ( ) ) ;
295+ return Ok ( future:: ready ( Ok (
296+ Canonical :: empty ( & expr. return_dtype ( self . dtype ( ) ) ?) . into_array ( )
297+ ) )
298+ . boxed ( ) ) ;
296299 }
297300
298301 let mut chunk_evals = vec ! [ ] ;
@@ -311,13 +314,16 @@ impl LayoutReader for ChunkedReader {
311314 // Split the mask over each chunk.
312315 let chunks: Vec < _ > = FuturesOrdered :: from_iter ( chunk_evals) . try_collect ( ) . await ?;
313316
317+ vortex_ensure ! ( !chunks. is_empty( ) , "Empty chunks were checked earlier" ) ;
318+
314319 // If there is only one chunk, we can return it directly.
315320 if chunks. len ( ) == 1 {
316321 return Ok ( chunks. into_iter ( ) . next ( ) . vortex_expect ( "one chunk" ) ) ;
317322 }
318323
324+ let return_dtype = chunks[ 0 ] . dtype ( ) . clone ( ) ;
319325 // Combine the arrays.
320- Ok ( ChunkedArray :: try_new ( chunks, dtype ) ?. into_array ( ) )
326+ Ok ( ChunkedArray :: try_new ( chunks, return_dtype ) ?. into_array ( ) )
321327 }
322328 . boxed ( ) )
323329 }
0 commit comments