-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-10783: [Rust] [DataFusion] Implement row count statistics for Parquet TableProviderParquet statistics [WIP] #8860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
114f83c
d2e892b
ad27fd6
239ebca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,14 +30,15 @@ use crate::physical_plan::{common, Partitioning}; | |
| use arrow::datatypes::{Schema, SchemaRef}; | ||
| use arrow::error::{ArrowError, Result as ArrowResult}; | ||
| use arrow::record_batch::RecordBatch; | ||
| use parquet::file::reader::SerializedFileReader; | ||
| use parquet::file::reader::{SerializedFileReader, FileReader}; | ||
|
|
||
| use crossbeam::channel::{bounded, Receiver, RecvError, Sender}; | ||
| use fmt::Debug; | ||
| use parquet::arrow::{ArrowReader, ParquetFileArrowReader}; | ||
|
|
||
| use async_trait::async_trait; | ||
| use futures::stream::Stream; | ||
| use crate::datasource::datasource::Statistics; | ||
|
|
||
| /// Execution plan for scanning a Parquet file | ||
| #[derive(Debug, Clone)] | ||
|
|
@@ -99,6 +100,38 @@ impl ParquetExec { | |
| batch_size, | ||
| } | ||
| } | ||
|
|
||
| /// Get the statistics from parquet file format | ||
| pub fn statistics(&self) -> Option<Statistics> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By doing this you are parsing the parquet file headers a second time when they have already been parsed.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, for clarity, the ParquetReader already performs this code. You could expose the metadata produced in the first pass and then you don't need to reimplement this logic (which has to read all the files again). |
||
| let mut num_rows = 0; | ||
| let mut total_byte_size = 0; | ||
| for i in 0..self.filenames.len() { | ||
| let file = File::open(&self.filenames[i]).ok()?; | ||
| let file_reader = Arc::new(SerializedFileReader::new(file).ok()?); | ||
| num_rows += file_reader.metadata().file_metadata().num_rows() as i64; | ||
| for g in file_reader.metadata().row_groups().iter() { | ||
| total_byte_size += g.total_byte_size() as i64; | ||
| } | ||
| } | ||
|
|
||
| if num_rows >= i64::MAX { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: you could use |
||
| num_rows = i64::MAX; | ||
| } | ||
| if total_byte_size >= i64::MAX { | ||
| total_byte_size = i64::MAX; | ||
| } | ||
| if num_rows <= 0 { | ||
| num_rows = 0; | ||
| } | ||
| if total_byte_size <= 0 { | ||
| total_byte_size = 0; | ||
| } | ||
|
|
||
| Option::from(Statistics{ | ||
| num_rows, | ||
| total_byte_size, | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is repeating what you have done in #8831
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Mike, this is just a draft code for WIP, when #8831 have been merged I'll recommit it.