JeonDaehong commented on code in PR #3698:
URL: https://github.com/apache/iceberg-rust/pull/3698#discussion_r4599703329


##########
crates/iceberg/src/delete_file_index.rs:
##########
@@ -370,6 +368,21 @@ impl PopulatedDeleteFileIndex {
                         .unwrap_or(true)
                 })
             {
+                let delete_data_file = delete.manifest_entry.data_file();
+                if data_file.partition_spec_id != delete.partition_spec_id

Review Comment:
   Same check and the same order as Java (sequence filter first, then 
`validatePartitionMatch`), so a stale delete with a mismatched partition is 
still skipped rather than rejected.



##########
crates/iceberg/src/delete_file_index.rs:
##########
@@ -370,6 +368,21 @@ impl PopulatedDeleteFileIndex {
                         .unwrap_or(true)
                 })
             {
+                let delete_data_file = delete.manifest_entry.data_file();
+                if data_file.partition_spec_id != delete.partition_spec_id
+                    || data_file.partition() != delete_data_file.partition()

Review Comment:
   `Struct` equality is type-sensitive where Java uses the spec's comparator, 
but `fetch_manifest_and_stream_manifest_entries` widens promoted int/float 
partition tuples (#3483) before entries reach the index, so a source promoted 
from int to long still compares like-typed here.



##########
crates/iceberg/src/delete_file_index.rs:
##########
@@ -650,6 +663,73 @@ mod tests {
         assert!(deletes_for_b.is_empty());
     }
 
+    #[test]
+    fn test_pos_delete_with_referenced_data_file_matches_partition() {
+        let partition = Struct::from_iter([Some(Literal::long(100))]);
+        let spec_id = 1;
+        let data_file = build_partitioned_data_file(&partition, spec_id);
+        let pos_delete =
+            build_partitioned_pos_delete_referencing(data_file.file_path(), 
&partition, spec_id);
+        let index = PopulatedDeleteFileIndex::new(vec![DeleteFileContext {
+            manifest_entry: build_added_manifest_entry(5, &pos_delete).into(),
+            partition_spec_id: spec_id,
+        }])
+        .unwrap();
+
+        let deletes = index
+            .get_deletes_for_data_file(&data_file, Some(0))
+            .unwrap();
+
+        assert_eq!(deletes.len(), 1);
+        assert_eq!(deletes[0].file_path(), pos_delete.file_path());
+    }
+
+    #[test]
+    fn 
test_pos_delete_with_referenced_data_file_rejects_mismatched_partition_spec() {
+        let partition = Struct::from_iter([Some(Literal::long(100))]);
+        let data_file = build_partitioned_data_file(&partition, 1);
+        let pos_delete =
+            build_partitioned_pos_delete_referencing(data_file.file_path(), 
&partition, 2);
+        let index = PopulatedDeleteFileIndex::new(vec![DeleteFileContext {
+            manifest_entry: build_added_manifest_entry(5, &pos_delete).into(),
+            partition_spec_id: 2,
+        }])
+        .unwrap();
+
+        let err = index
+            .get_deletes_for_data_file(&data_file, Some(0))
+            .unwrap_err();
+
+        assert_eq!(err.kind(), ErrorKind::DataInvalid);
+        assert!(err.message().contains("partition"));
+    }
+
+    #[test]
+    fn test_pos_delete_with_equal_path_bounds_rejects_mismatched_partition() {

Review Comment:
   Removing the check makes this test and 
`test_pos_delete_with_referenced_data_file_rejects_mismatched_partition_spec` 
fail, so both the bounds-derived and the `referenced_data_file` paths are 
covered.



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