Copilot commented on code in PR #3522:
URL: https://github.com/apache/iceberg-rust/pull/3522#discussion_r4578532043


##########
crates/iceberg/src/spec/values/datum.rs:
##########
@@ -1236,14 +1256,45 @@ impl Datum {
     }
 
     /// Returns a copy whose literal is widened to `target` for the value
-    /// promotions `int` -> `long` and `float` -> `double`, so a value written
-    /// under the narrower type compares against a predicate bound to the wider
-    /// one. Returns `None` when `target` does not widen this value (decimals
-    /// already compare across precisions), so callers can avoid a copy.
-    pub(crate) fn promote_to(&self, target: &PrimitiveType) -> Option<Datum> {
-        self.literal
-            .promote_to(target)
-            .map(|literal| Datum::new(target.clone(), literal))
+    /// promotions `int` -> `long`, `float` -> `double`, and `date` -> 
`timestamp` /
+    /// `timestamp_ns`, so a value written under the narrower type compares 
against
+    /// a predicate bound to the wider one. Returns `Ok(None)` when `target` 
does not
+    /// widen this value (decimals already compare across precisions), so 
callers
+    /// can avoid a copy.
+    ///
+    /// Matches on `(self.data_type(), target)` so an `int` literal is not 
treated as
+    /// a date.
+    ///
+    /// # Errors
+    /// Returns `DataInvalid` if a date is outside the range of the target 
timestamp
+    /// type.
+    pub(crate) fn promote_to(&self, target: &PrimitiveType) -> 
Result<Option<Datum>> {

Review Comment:
   Changing this return type leaves `bound_as_column_type` in 
`crates/iceberg/src/scan/task.rs:874` matching `if let Some(promoted) = 
bound.promote_to(column_type)`. That expression now returns 
`Result<Option<Datum>>`, so the unconditionally compiled scan module fails to 
type-check. Update that caller and its statistics-building path to handle the 
result, with an explicit policy for promotion overflow.



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

Reply via email to