efredine commented on code in PR #11200:
URL: https://github.com/apache/datafusion/pull/11200#discussion_r1663023578


##########
datafusion/core/src/datasource/physical_plan/parquet/statistics.rs:
##########
@@ -903,6 +917,21 @@ macro_rules! get_data_page_statistics {
                             new_empty_array(&DataType::Time64(unit.clone()))
                         }
                     })
+                },
+                Some(DataType::FixedSizeBinary(size)) => {
+                    Ok(Arc::new(
+                        FixedSizeBinaryArray::from(
+                            [<$stat_type_prefix 
FixedLenByteArrayDataPageStatsIterator>]::new($iterator).map(|x| {
+                                x.into_iter().filter_map(|x| x).map(|x| {
+                                    if x.len().try_into() == Ok(*size) {
+                                            Some(x.data().to_vec())
+                                        } else {
+                                            None
+                                        }
+                                })
+                            }).flatten().collect::<Vec<_>>()
+                        )
+                    ))

Review Comment:
   This seems to work, but feels like it should be possible to simplify it:
   ```Rust
                   Some(DataType::FixedSizeBinary(size)) => {
                       Ok(Arc::new(FixedSizeBinaryArray::from(
                           [<$stat_type_prefix 
FixedLenByteArrayDataPageStatsIterator>]::new($iterator)
                               .flat_map(|x| x.into_iter()) // Convert 
Vec<Option<FixedLenByteArray>> into an iterator of Option<FixedLenByteArray>
                               .filter_map(|x| x) // Filter out None values, 
yielding FixedLenByteArray
                               .map(|x| x.data().to_vec()) // Convert 
FixedLenByteArray to Vec<u8>
                               .filter(|x| x.len().try_into() == Ok(*size)) // 
Ensure the byte vector has the correct size
                               .collect::<Vec<Vec<u8>>>() // Collect into 
Vec<Vec<u8>>
                               .iter() // Iterate over Vec<Vec<u8>>
                               .map(|x| x.as_slice()) // Convert Vec<u8> to 
&[u8]
                               .collect::<Vec<&[u8]>>() // Collect into 
Vec<&[u8]>
                       )))
                   },
   ```



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to