leaves12138 commented on code in PR #739:
URL: https://github.com/apache/paimon-rust/pull/739#discussion_r3838068942


##########
crates/paimon/src/table/source.rs:
##########
@@ -1295,6 +1295,19 @@ impl Plan {
         &self.splits
     }
 
+    /// Sum of data-file bytes referenced by this plan.
+    ///
+    /// Negative file sizes are treated as unknown and do not contribute. The
+    /// result is therefore a lower bound when a connector cannot provide every
+    /// file size.
+    pub fn planned_data_file_bytes(&self) -> u64 {
+        self.splits
+            .iter()
+            .flat_map(DataSplit::data_files)
+            .filter_map(|file| u64::try_from(file.file_size).ok())
+            .sum()

Review Comment:
   Could we make this accumulation overflow-safe (for example, with 
`saturating_add`)? `sum::<u64>()` panics with overflow checks enabled and wraps 
in release builds when the total known file bytes exceeds `u64::MAX`. Because 
this value is used for query-budget enforcement, wrapping can under-report an 
oversized plan and let it pass the budget check. Saturating at `u64::MAX` 
preserves the safety property; please also add an overflow regression test.



-- 
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]

Reply via email to