alamb commented on code in PR #22360:
URL: https://github.com/apache/datafusion/pull/22360#discussion_r3320519480
##########
datafusion/datasource-parquet/src/opener/mod.rs:
##########
@@ -713,8 +713,14 @@ impl PreparedParquetOpen {
// unnecessary I/O. We decide later if it is needed to evaluate the
// pruning predicates. Thus default to not requesting it from the
// underlying reader.
- let options =
-
ArrowReaderOptions::new().with_page_index_policy(PageIndexPolicy::Skip);
+ let options = {
+ let mut options =
+
ArrowReaderOptions::new().with_page_index_policy(PageIndexPolicy::Skip);
+ if let Some(schema) = self.partitioned_file.arrow_schema.as_ref() {
+ options = options.with_schema(schema.to_owned());
Review Comment:
I also think the `to_owned()` call is a non standard way of cloning a schema
```rust
options = options.with_schema(schema.to_owned());
```
I think the more standard / explicit way is
```rust
options = options.with_schema(Arc::clone(schema));
```
##########
datafusion/datasource-parquet/src/opener/mod.rs:
##########
@@ -713,8 +713,14 @@ impl PreparedParquetOpen {
// unnecessary I/O. We decide later if it is needed to evaluate the
// pruning predicates. Thus default to not requesting it from the
// underlying reader.
- let options =
-
ArrowReaderOptions::new().with_page_index_policy(PageIndexPolicy::Skip);
+ let options = {
+ let mut options =
+
ArrowReaderOptions::new().with_page_index_policy(PageIndexPolicy::Skip);
+ if let Some(schema) = self.partitioned_file.arrow_schema.as_ref() {
+ options = options.with_schema(schema.to_owned());
+ }
+ options
+ };
Review Comment:
I think this could be collapsed / simplified:
```suggestion
let mut options =
ArrowReaderOptions::new().with_page_index_policy(PageIndexPolicy::Skip);
if let Some(schema) = self.partitioned_file.arrow_schema.as_ref() {
options = options.with_schema(schema.to_owned());
}
```
--
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]