etseidl commented on code in PR #8817:
URL: https://github.com/apache/arrow-rs/pull/8817#discussion_r2516054432
##########
parquet/src/file/metadata/writer.rs:
##########
@@ -227,22 +231,38 @@ impl<'a, W: Write> ThriftMetadataWriter<'a, W> {
None => builder.set_row_groups(row_groups),
};
- let column_indexes: Option<ParquetColumnIndex> =
column_indexes.map(|ovvi| {
- ovvi.into_iter()
- .map(|vi| {
- vi.into_iter()
- .map(|oi| oi.unwrap_or(ColumnIndexMetaData::NONE))
- .collect()
- })
- .collect()
- });
-
- // FIXME(ets): this will panic if there's a missing index.
- let offset_indexes: Option<ParquetOffsetIndex> =
offset_indexes.map(|ovvi| {
- ovvi.into_iter()
- .map(|vi| vi.into_iter().map(|oi| oi.unwrap()).collect())
- .collect()
- });
+ // test to see if all indexes for this file are empty
+ let all_none = column_indexes
+ .as_ref()
+ .is_some_and(|ci| ci.iter().all(|cii| cii.iter().all(|idx|
idx.is_none())));
+ let column_indexes: Option<ParquetColumnIndex> = if all_none {
+ None
+ } else {
+ column_indexes.map(|ovvi| {
+ ovvi.into_iter()
+ .map(|vi| {
+ vi.into_iter()
+ .map(|oi| oi.unwrap_or(ColumnIndexMetaData::NONE))
+ .collect()
+ })
+ .collect()
+ })
+ };
+
+ // test to see if all indexes for this file are empty
+ let all_none = offset_indexes
+ .as_ref()
+ .is_some_and(|oi| oi.iter().all(|oii| oii.iter().all(|idx|
idx.is_none())));
+ let offset_indexes: Option<ParquetOffsetIndex> = if all_none {
+ None
+ } else {
+ // FIXME(ets): this will panic if there's a missing index.
Review Comment:
I only added a test for *all* none, so it's conceivable there could be rogue
`None` in there someplace.
I think this ties in with #8818. Allowing `None` in the final index would
fix this.
--
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]