This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 6af5c954b4 feat: Add new() constructor for CachedParquetFileReader
(#18575)
6af5c954b4 is described below
commit 6af5c954b41f539ac2f418c53393aad606f135b0
Author: Peter Nguyen <[email protected]>
AuthorDate: Wed Nov 12 06:43:17 2025 -0800
feat: Add new() constructor for CachedParquetFileReader (#18575)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Closes #18145
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
Allows constructing `CachedParquetFileReader::new()` manually, allowing
users to create it with a custom object reader (inner) object.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
Adds a simple constructor for `CachedParquetFileReader`
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
Added a test
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
Yes, new constructor available
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---
datafusion/datasource-parquet/src/reader.rs | 30 ++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/datafusion/datasource-parquet/src/reader.rs
b/datafusion/datasource-parquet/src/reader.rs
index 88a3cea562..6670109cf7 100644
--- a/datafusion/datasource-parquet/src/reader.rs
+++ b/datafusion/datasource-parquet/src/reader.rs
@@ -208,14 +208,14 @@ impl ParquetFileReaderFactory for
CachedParquetFileReaderFactory {
inner = inner.with_footer_size_hint(hint)
};
- Ok(Box::new(CachedParquetFileReader {
- store: Arc::clone(&self.store),
- inner,
+ Ok(Box::new(CachedParquetFileReader::new(
file_metrics,
+ Arc::clone(&self.store),
+ inner,
partitioned_file,
- metadata_cache: Arc::clone(&self.metadata_cache),
+ Arc::clone(&self.metadata_cache),
metadata_size_hint,
- }))
+ )))
}
}
@@ -231,6 +231,26 @@ pub struct CachedParquetFileReader {
metadata_size_hint: Option<usize>,
}
+impl CachedParquetFileReader {
+ pub fn new(
+ file_metrics: ParquetFileMetrics,
+ store: Arc<dyn ObjectStore>,
+ inner: ParquetObjectReader,
+ partitioned_file: PartitionedFile,
+ metadata_cache: Arc<dyn FileMetadataCache>,
+ metadata_size_hint: Option<usize>,
+ ) -> Self {
+ Self {
+ file_metrics,
+ store,
+ inner,
+ partitioned_file,
+ metadata_cache,
+ metadata_size_hint,
+ }
+ }
+}
+
impl AsyncFileReader for CachedParquetFileReader {
fn get_bytes(
&mut self,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]