File tree Expand file tree Collapse file tree
datafusion/datasource-avro/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,7 +46,9 @@ pub fn read_avro_schema_from_reader<R: Read>(
4646 // that are stricter than DataFusion's table schema handling needs for inferred schemas.
4747 // Drop metadata from inferred schemas so runtime batches and inferred table schemas
4848 // compare consistently without requiring strict Avro metadata identity.
49- Ok ( strip_metadata_from_schema ( avro_reader. schema ( ) . as_ref ( ) . clone ( ) ) )
49+ Ok ( strip_metadata_from_schema (
50+ avro_reader. schema ( ) . as_ref ( ) . clone ( ) ,
51+ ) )
5052}
5153
5254fn strip_metadata_from_schema ( schema : Schema ) -> Schema {
@@ -86,10 +88,9 @@ fn strip_metadata_from_data_type(data_type: &DataType) -> DataType {
8688 Arc :: new ( strip_metadata_from_field ( field. as_ref ( ) ) ) ,
8789 * size,
8890 ) ,
89- DataType :: Map ( field, sorted) => DataType :: Map (
90- Arc :: new ( strip_metadata_from_field ( field. as_ref ( ) ) ) ,
91- * sorted,
92- ) ,
91+ DataType :: Map ( field, sorted) => {
92+ DataType :: Map ( Arc :: new ( strip_metadata_from_field ( field. as_ref ( ) ) ) , * sorted)
93+ }
9394 _ => data_type. clone ( ) ,
9495 }
9596}
Original file line number Diff line number Diff line change @@ -54,11 +54,15 @@ impl AvroSource {
5454 }
5555
5656 fn open < R : std:: io:: BufRead > ( & self , reader : R ) -> Result < Reader < R > > {
57- ReaderBuilder :: new ( )
58- . with_batch_size ( self . batch_size . expect ( "Batch size must set before open" ) )
59- . with_projection ( self . projection . file_indices . clone ( ) )
60- . build ( reader)
61- . map_err ( Into :: into)
57+ let mut builder = ReaderBuilder :: new ( )
58+ . with_batch_size ( self . batch_size . expect ( "Batch size must set before open" ) ) ;
59+
60+ // Avoid pushing an empty projection into arrow-avro.
61+ if !self . projection . file_indices . is_empty ( ) {
62+ builder = builder. with_projection ( self . projection . file_indices . clone ( ) ) ;
63+ }
64+
65+ builder. build ( reader) . map_err ( Into :: into)
6266 }
6367}
6468
You can’t perform that action at this time.
0 commit comments