From 71cfed9d81c1e3977cef186d84c61dcd033604fa Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies Date: Wed, 1 Jun 2022 10:45:36 +0100 Subject: [PATCH] Improve ParquetFileArrowReader UX --- parquet/src/arrow/arrow_reader.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/parquet/src/arrow/arrow_reader.rs b/parquet/src/arrow/arrow_reader.rs index 34a14f3725f7..23e2398e0f88 100644 --- a/parquet/src/arrow/arrow_reader.rs +++ b/parquet/src/arrow/arrow_reader.rs @@ -32,6 +32,7 @@ use crate::arrow::ProjectionMask; use crate::errors::Result; use crate::file::metadata::{KeyValue, ParquetMetaData}; use crate::file::reader::FileReader; +use crate::schema::types::SchemaDescriptor; /// Arrow reader api. /// With this api, user can get arrow schema from parquet file, and read parquet data @@ -164,10 +165,21 @@ impl ParquetFileArrowReader { } /// Expose the reader metadata + #[deprecated = "use metadata() instead"] pub fn get_metadata(&mut self) -> ParquetMetaData { self.file_reader.metadata().clone() } + /// Returns the parquet metadata + pub fn metadata(&self) -> &ParquetMetaData { + self.file_reader.metadata() + } + + /// Returns the parquet schema + pub fn parquet_schema(&self) -> &SchemaDescriptor { + self.file_reader.metadata().file_metadata().schema_descr() + } + /// Returns the key value metadata, returns `None` if [`ArrowReaderOptions::skip_arrow_metadata`] fn get_kv_metadata(&self) -> Option<&Vec> { if self.options.skip_arrow_metadata {