use crate::datatypes::Schema;
use crate::error::Result;
mod convert;
mod metadata;
pub use convert::parquet_to_arrow_schema;
pub use metadata::read_schema_from_metadata;
pub use parquet2::metadata::{FileMetaData, KeyValue, SchemaDescriptor};
pub use parquet2::schema::types::ParquetType;
pub(crate) use convert::*;
use self::metadata::parse_key_value_metadata;
pub fn infer_schema(file_metadata: &FileMetaData) -> Result<Schema> {
let mut metadata = parse_key_value_metadata(file_metadata.key_value_metadata());
let schema = read_schema_from_metadata(&mut metadata)?;
Ok(schema.unwrap_or_else(|| {
let fields = parquet_to_arrow_schema(file_metadata.schema().fields());
Schema { fields, metadata }
}))
}