anoopj commented on code in PR #3483:
URL: https://github.com/apache/iceberg-rust/pull/3483#discussion_r4332114830


##########
crates/iceberg/src/spec/manifest/data_file.rs:
##########
@@ -184,7 +186,36 @@ pub struct DataFile {
     pub(crate) content_size_in_bytes: Option<i64>,
 }
 
+fn promote_partition_value(value: Option<&Literal>, field: &NestedFieldRef) -> 
Option<Literal> {
+    match value {
+        Some(Literal::Primitive(primitive)) => {
+            let promoted = match field.field_type.as_primitive_type() {
+                // The partition source column was dropped, so there is no 
target type to
+                // widen to; widen to the promotion ceiling instead so this 
value and its
+                // deletes still normalize to the same type and the delete 
index matches.
+                Some(PrimitiveType::Unknown) => primitive.widen(),
+                Some(target) => primitive.promote_to(target),
+                None => None,
+            };
+            promoted.map(Literal::Primitive).or_else(|| value.cloned())
+        }
+        other => other.cloned(),
+    }
+}
+
 impl DataFile {
+    /// Returns this file's partition tuple widened to `partition_type` for 
fields
+    /// promoted (`int` -> `long`, `float` -> `double`) since the file's 
manifest
+    /// was written. Values whose type is unchanged are copied through. Column
+    /// bounds are widened separately, lazily, where they are compared.
+    pub(crate) fn promoted_partition(&self, partition_type: &StructType) -> 
Struct {
+        self.partition
+            .iter()
+            .zip(partition_type.fields())
+            .map(|(value, field)| promote_partition_value(value, field))
+            .collect()
+    }

Review Comment:
   Good catch. Fixed such that it now returns `DataInvalid`. 



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