File tree Expand file tree Collapse file tree 2 files changed +17
-18
lines changed
datafusion/src/datasource Expand file tree Collapse file tree 2 files changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ use std::mem::size_of;
2626use std:: ops:: { Add , Div , Mul , Sub } ;
2727use std:: slice:: from_raw_parts;
2828use std:: str:: FromStr ;
29- use std:: sync:: Arc ;
3029
3130use packed_simd:: * ;
3231use serde_derive:: { Deserialize , Serialize } ;
@@ -752,22 +751,6 @@ impl Schema {
752751 "fields" : self . fields. iter( ) . map( |field| field. to_json( ) ) . collect:: <Vec <Value >>( ) ,
753752 } )
754753 }
755-
756- /// Create a new schema by applying a projection to this schema's fields
757- pub fn projection ( & self , projection : & [ usize ] ) -> Result < Arc < Schema > > {
758- let mut fields: Vec < Field > = Vec :: with_capacity ( projection. len ( ) ) ;
759- for i in projection {
760- if * i < self . fields ( ) . len ( ) {
761- fields. push ( self . field ( * i) . clone ( ) ) ;
762- } else {
763- return Err ( ArrowError :: InvalidArgumentError ( format ! (
764- "Invalid column index {} in projection" ,
765- i
766- ) ) ) ;
767- }
768- }
769- Ok ( Arc :: new ( Schema :: new ( fields) ) )
770- }
771754}
772755
773756impl fmt:: Display for Schema {
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ impl ParquetFile {
208208 }
209209 } ;
210210
211- let projected_schema = schema . projection ( & projection) ?;
211+ let projected_schema = schema_projection ( & schema , & projection) ?;
212212
213213 Ok ( ParquetFile {
214214 reader : reader,
@@ -337,6 +337,22 @@ impl ParquetFile {
337337 }
338338}
339339
340+ /// Create a new schema by applying a projection to this schema's fields
341+ fn schema_projection ( schema : & Schema , projection : & [ usize ] ) -> Result < Arc < Schema > > {
342+ let mut fields: Vec < Field > = Vec :: with_capacity ( projection. len ( ) ) ;
343+ for i in projection {
344+ if * i < schema. fields ( ) . len ( ) {
345+ fields. push ( schema. field ( * i) . clone ( ) ) ;
346+ } else {
347+ return Err ( ExecutionError :: InvalidColumn ( format ! (
348+ "Invalid column index {} in projection" ,
349+ i
350+ ) ) ) ;
351+ }
352+ }
353+ Ok ( Arc :: new ( Schema :: new ( fields) ) )
354+ }
355+
340356/// convert a Parquet INT96 to an Arrow timestamp in nanoseconds
341357fn convert_int96_timestamp ( v : & [ u32 ] ) -> i64 {
342358 const JULIAN_DAY_OF_EPOCH : i64 = 2_440_588 ;
You can’t perform that action at this time.
0 commit comments