qzyu999 commented on code in PR #23656:
URL: https://github.com/apache/datafusion/pull/23656#discussion_r3679384497
##########
datafusion/datasource-parquet/src/sink.rs:
##########
@@ -411,6 +411,31 @@ impl DataSink for ParquetSink {
) -> Result<u64> {
FileSink::write_all(self, data, context).await
}
+
+ fn file_metadata(&self) -> Vec<FileWriteMetadata> {
+ let written = self.written.lock();
+ written
+ .iter()
+ .map(|(path, parquet_meta)| {
+ let row_count = parquet_meta.file_metadata().num_rows() as u64;
+ let byte_size: u64 = parquet_meta
+ .row_groups()
+ .iter()
+ .map(|rg| rg.compressed_size() as u64)
+ .sum();
Review Comment:
Replaced both casts with `try_into().unwrap_or(0)`:
```rust
let row_count: u64 = parquet_meta
.file_metadata()
.num_rows()
.try_into()
.unwrap_or(0);
let byte_size: u64 = parquet_meta
.row_groups()
.iter()
.map(|rg| u64::try_from(rg.compressed_size()).unwrap_or(0))
.sum();
```
Also updated the `file_metadata_consistent_with_written` test assertions to
use the same safe conversion pattern.
--
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]