File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -381,6 +381,10 @@ impl<T: DataType> DictDecoder<T> {
381381impl < T : DataType > Decoder < T > for DictDecoder < T > {
382382 fn set_data ( & mut self , data : Bytes , num_values : usize ) -> Result < ( ) > {
383383 // First byte in `data` is bit width
384+ if data. len ( ) < 1 {
385+ return Err ( eof_err ! ( "Not enough bytes to decode bit_width" ) ) ;
386+ }
387+
384388 let bit_width = data. as_ref ( ) [ 0 ] ;
385389 if bit_width > 32 {
386390 return Err ( general_err ! (
Original file line number Diff line number Diff line change @@ -1348,19 +1348,19 @@ fn schema_from_array_helper<'a>(
13481348 . with_logical_type ( logical_type)
13491349 . with_fields ( fields)
13501350 . with_id ( field_id) ;
1351- if let Some ( rep ) = repetition {
1352- // Sometimes parquet-cpp and parquet-mr set repetition level REQUIRED or
1353- // REPEATED for root node.
1354- //
1355- // We only set repetition for group types that are not top-level message
1356- // type. According to parquet-format:
1357- // Root of the schema does not have a repetition_type.
1358- // All other types must have one.
1359- if !is_root_node {
1360- builder = builder . with_repetition ( rep ) ;
1361- }
1362- } else if !is_root_node {
1363- return Err ( general_err ! ( "Repetition level must be defined for non-root types" ) ) ;
1351+
1352+ // Sometimes parquet-cpp and parquet-mr set repetition level REQUIRED or
1353+ // REPEATED for root node.
1354+ //
1355+ // We only set repetition for group types that are not top-level message
1356+ // type. According to parquet-format:
1357+ // Root of the schema does not have a repetition_type.
1358+ // All other types must have one.
1359+ if !is_root_node {
1360+ let Some ( rep ) = repetition else {
1361+ return Err ( general_err ! ( "Repetition level must be defined for non-root types" ) ) ;
1362+ } ;
1363+ builder = builder . with_repetition ( rep ) ;
13641364 }
13651365 Ok ( ( next_index, Arc :: new ( builder. build ( ) . unwrap ( ) ) ) )
13661366 }
You can’t perform that action at this time.
0 commit comments