getChan commented on code in PR #17861: URL: https://github.com/apache/datafusion/pull/17861#discussion_r2562657694
########## datafusion/datasource-avro/src/mod.rs: ########## @@ -26,9 +26,19 @@ //! An [Avro](https://avro.apache.org/) based [`FileSource`](datafusion_datasource::file::FileSource) implementation and related functionality. -pub mod avro_to_arrow; pub mod file_format; pub mod source; -pub use apache_avro; +use arrow::datatypes::Schema; +pub use arrow_avro; +use arrow_avro::reader::ReaderBuilder; pub use file_format::*; +use std::io::{BufReader, Read}; + +/// Read Avro schema given a reader +pub fn read_avro_schema_from_reader<R: Read>( + reader: &mut R, +) -> datafusion_common::Result<Schema> { + let avro_reader = ReaderBuilder::new().build(BufReader::new(reader))?; + Ok(avro_reader.schema().as_ref().clone()) +} Review Comment: @jecsand838 Thanks for your contribution! I have applied your suggestion and will run additional tests. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
