You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "williamhyun (via GitHub)" <gi...@apache.org> on 2026/08/03 17:22:41 UTC

[PR] Core: Fix delete file references for DVs in the same Puffin file [iceberg]

williamhyun opened a new pull request, #17497:
URL: https://github.com/apache/iceberg/pull/17497

   Motivation: Scan planning responses index delete files by position in the delete-files array. 
   The index map was keyed on the delete file location alone, but a single Puffin file can hold a deletion vector for each of several data files. Every DV in that file shares a location, so each new DV entry overwrote the previous one and every task referencing a DV in that Puffin file resolved to the same last index.
   
   Changes: Extract DeleteFileSet's private wrapper into a public DeleteFileWrapper, mirroring CharSequenceWrapper, and key the index map on it so serialization uses the same delete file identity that builds the delete-files array. 
   Fail with a clear message when a task references a delete file that is not in that array.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "williamhyun (via GitHub)" <gi...@apache.org>.
williamhyun commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3731240857


##########
core/src/main/java/org/apache/iceberg/rest/TableScanResponseParser.java:
##########
@@ -119,7 +121,12 @@ public static void serializeScanTasks(
         Set<Integer> deleteFileReferences = Sets.newHashSet();
         if (deleteFiles != null) {
           for (DeleteFile taskDelete : fileScanTask.deletes()) {
-            deleteFileReferences.add(deleteFilePathToIndex.get(taskDelete.location()));
+            Integer index = deleteFileToIndex.get(DeleteFileWrapper.wrap(taskDelete));
+            Preconditions.checkArgument(
+                index != null,
+                "Cannot serialize scan task with delete file missing from delete files: %s",

Review Comment:
   +1, 
   Added `TestTableScanResponseParser#cannotSerializeScanTaskWithDeleteFileMissingFromDeleteFiles`.
   
   This branch isn't reachable via the response parsers. The only builder path to a mismatch is the deprecated `withDeleteFiles` (aimed for removal in 1.12.0), so the test calls `serializeScanTasks` directly, which fits best in its own class.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3709908950


##########
api/src/main/java/org/apache/iceberg/util/DeleteFileWrapper.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.util;
+
+import java.util.Objects;
+import org.apache.iceberg.DeleteFile;
+
+/**
+ * Wrapper class to adapt DeleteFile for use in maps and sets.
+ *
+ * <p>Delete files are identified by location and content range rather than location alone, as a
+ * single Puffin file can hold multiple deletion vectors.
+ */
+public class DeleteFileWrapper implements WrapperSet.Wrapper<DeleteFile> {

Review Comment:
   Now that we're exposing this class we should probably have a `TestDeleteFileWrapper`



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "singhpk234 (via GitHub)" <gi...@apache.org>.
singhpk234 merged PR #17497:
URL: https://github.com/apache/iceberg/pull/17497


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "Tishj (via GitHub)" <gi...@apache.org>.
Tishj commented on PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#issuecomment-5236386206

   I believe this PR fixes https://github.com/apache/iceberg/issues/17334


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3726897800


##########
core/src/main/java/org/apache/iceberg/rest/TableScanResponseParser.java:
##########
@@ -119,7 +121,12 @@ public static void serializeScanTasks(
         Set<Integer> deleteFileReferences = Sets.newHashSet();
         if (deleteFiles != null) {
           for (DeleteFile taskDelete : fileScanTask.deletes()) {
-            deleteFileReferences.add(deleteFilePathToIndex.get(taskDelete.location()));
+            Integer index = deleteFileToIndex.get(DeleteFileWrapper.wrap(taskDelete));
+            Preconditions.checkArgument(
+                index != null,
+                "Cannot serialize scan task with delete file missing from delete files: %s",

Review Comment:
   I don't see this being exercised anywhere, so would be good to have a 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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3707862698


##########
api/src/main/java/org/apache/iceberg/util/DeleteFileWrapper.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.util;
+
+import java.util.Objects;
+import org.apache.iceberg.DeleteFile;
+
+/**
+ * Wrapper class to adapt DeleteFile for use in maps and sets.
+ *
+ * <p>Delete files are identified by location and content range rather than location alone, as a
+ * single Puffin file can hold a deletion vector for each of several data files.
+ */
+public class DeleteFileWrapper implements WrapperSet.Wrapper<DeleteFile> {

Review Comment:
   I looked at other approaches (like how difficult it would be to make DeleteFileSet an indexed structure since it does store in insertion order, but removals get complicated etc). So I came to the conclusion that fundamentally we do need to expose DeleteFile equality as is done here via the wrapper.



##########
core/src/main/java/org/apache/iceberg/rest/TableScanResponseParser.java:
##########


Review Comment:
   I was looking at this and in hindsight I think it would've been better to pass in Iterables for both of these. In the end this implementation takes the responsibility of tracking the positions, it's not like we need to rely on the caller to pass in an explicit List.



##########
api/src/main/java/org/apache/iceberg/util/DeleteFileWrapper.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.util;
+
+import java.util.Objects;
+import org.apache.iceberg.DeleteFile;
+
+/**
+ * Wrapper class to adapt DeleteFile for use in maps and sets.
+ *
+ * <p>Delete files are identified by location and content range rather than location alone, as a
+ * single Puffin file can hold a deletion vector for each of several data files.

Review Comment:
   "single Puffin file can hold multiple DVs"? a DV is already known to be 1:1 for a data file so I don't think we need the "each of several data files"



##########
core/src/main/java/org/apache/iceberg/rest/TableScanResponseParser.java:
##########
@@ -99,14 +100,14 @@ public static void serializeScanTasks(
       Map<Integer, PartitionSpec> specsById,
       JsonGenerator gen)
       throws IOException {
-    Map<String, Integer> deleteFilePathToIndex = Maps.newHashMap();
+    Map<DeleteFileWrapper, Integer> deleteFileToIndex = Maps.newHashMap();

Review Comment:
   I would just add a 1 line comment maybe explaining DeleteFileWrapper is important here.



##########
api/src/main/java/org/apache/iceberg/util/DeleteFileWrapper.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.util;
+
+import java.util.Objects;
+import org.apache.iceberg.DeleteFile;
+
+/**
+ * Wrapper class to adapt DeleteFile for use in maps and sets.
+ *
+ * <p>Delete files are identified by location and content range rather than location alone, as a
+ * single Puffin file can hold a deletion vector for each of several data files.
+ */
+public class DeleteFileWrapper implements WrapperSet.Wrapper<DeleteFile> {

Review Comment:
   And I think any other kind of implementation would basically be a O(n) lookup when trying to find the index to serialize (the mapping from delete file to position in the protocol) into the response which feels needlessly suboptimal to just exposing this. 



##########
core/src/main/java/org/apache/iceberg/rest/TableScanResponseParser.java:
##########
@@ -99,14 +100,14 @@ public static void serializeScanTasks(
       Map<Integer, PartitionSpec> specsById,
       JsonGenerator gen)
       throws IOException {
-    Map<String, Integer> deleteFilePathToIndex = Maps.newHashMap();
+    Map<DeleteFileWrapper, Integer> deleteFileToIndex = Maps.newHashMap();

Review Comment:
   Normally, I think I'd have this map be defined to the interface `DeleteFile` (and the implementation just uses the DeleteFileWrapper when populating for correctness of the fix) but in this case I think it's actually better to define it to the  concrete implementation as it's done here because it makes it clear that this really does need to be the wrapper for proper uniqueness comparison. It guarantees that if someone changes the below logic to populate some other type of DeleteFile that we're doing something wrong.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "singhpk234 (via GitHub)" <gi...@apache.org>.
singhpk234 commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3708349387


##########
api/src/main/java/org/apache/iceberg/util/DeleteFileWrapper.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.util;
+
+import java.util.Objects;
+import org.apache.iceberg.DeleteFile;
+
+/**
+ * Wrapper class to adapt DeleteFile for use in maps and sets.
+ *
+ * <p>Delete files are identified by location and content range rather than location alone, as a
+ * single Puffin file can hold multiple deletion vectors.
+ */
+public class DeleteFileWrapper implements WrapperSet.Wrapper<DeleteFile> {
+  public static DeleteFileWrapper wrap(DeleteFile deleteFile) {
+    return new DeleteFileWrapper(deleteFile);
+  }
+
+  private DeleteFile file;
+
+  private DeleteFileWrapper(DeleteFile file) {
+    this.file = file;
+  }
+
+  @Override
+  public DeleteFile get() {
+    return file;
+  }
+
+  @Override
+  public DeleteFileWrapper set(DeleteFile deleteFile) {
+    this.file = deleteFile;
+    return this;
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (this == other) {
+      return true;
+    }
+
+    if (!(other instanceof DeleteFileWrapper)) {
+      return false;
+    }
+
+    DeleteFileWrapper that = (DeleteFileWrapper) other;
+    return Objects.equals(file.location(), that.file.location())
+        && Objects.equals(file.contentOffset(), that.file.contentOffset())
+        && Objects.equals(file.contentSizeInBytes(), that.file.contentSizeInBytes());
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(file.location(), file.contentOffset(), file.contentSizeInBytes());
+  }
+
+  @Override
+  public String toString() {
+    return file.location();
+  }
+}

Review Comment:
   new line in the end



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "williamhyun (via GitHub)" <gi...@apache.org>.
williamhyun commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3708350088


##########
core/src/main/java/org/apache/iceberg/rest/TableScanResponseParser.java:
##########


Review Comment:
   @amogh-jahagirdar 
   Could we open this in a follow-up api change?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "singhpk234 (via GitHub)" <gi...@apache.org>.
singhpk234 commented on PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#issuecomment-5256450536

   Thanks for the change @williamhyun (can you please create this fix against 1.11 branch as well) ! thanks for review @amogh-jahagirdar @nastra !


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "singhpk234 (via GitHub)" <gi...@apache.org>.
singhpk234 commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3716099726


##########
core/src/test/java/org/apache/iceberg/util/TestDeleteFileWrapper.java:
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.util;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.iceberg.DeleteFile;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.FileMetadata;
+import org.apache.iceberg.PartitionSpec;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Testing {@link DeleteFileWrapper} is easier in iceberg-core since the delete file builders are
+ * located here
+ */
+public class TestDeleteFileWrapper {
+
+  private static final DeleteFile FILE_A_DELETES =
+      FileMetadata.deleteFileBuilder(PartitionSpec.unpartitioned())
+          .ofPositionDeletes()
+          .withPath("/path/to/data-a-deletes.parquet")
+          .withFileSizeInBytes(1)
+          .withRecordCount(1)
+          .build();
+  private static final DeleteFile FILE_B_DELETES =
+      FileMetadata.deleteFileBuilder(PartitionSpec.unpartitioned())
+          .ofPositionDeletes()
+          .withPath("/path/to/data-b-deletes.parquet")
+          .withFileSizeInBytes(2)
+          .withRecordCount(2)
+          .build();
+
+  private static DeleteFile dv(String path, long contentOffset, long contentSizeInBytes) {
+    return FileMetadata.deleteFileBuilder(PartitionSpec.unpartitioned())
+        .ofPositionDeletes()
+        .withPath(path)
+        .withFormat(FileFormat.PUFFIN)
+        .withFileSizeInBytes(100)
+        .withRecordCount(1)
+        .withReferencedDataFile("/path/to/data.parquet")
+        .withContentOffset(contentOffset)
+        .withContentSizeInBytes(contentSizeInBytes)
+        .build();
+  }

Review Comment:
   check if we can reuse these from the TestBase ? 
   https://github.com/apache/iceberg/blob/main/core/src/test/java/org/apache/iceberg/TestBase.java#L75



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3707852389


##########
core/src/main/java/org/apache/iceberg/rest/TableScanResponseParser.java:
##########
@@ -99,14 +100,14 @@ public static void serializeScanTasks(
       Map<Integer, PartitionSpec> specsById,
       JsonGenerator gen)
       throws IOException {
-    Map<String, Integer> deleteFilePathToIndex = Maps.newHashMap();
+    Map<DeleteFileWrapper, Integer> deleteFileToIndex = Maps.newHashMap();

Review Comment:
   Normally, I think I'd have this map be defined to the interface `DeleteFile` (and the implementation just uses the DeleteFileWrapper when populating for correctness of the fix) but in this case I think it's actually better to define it to the  concrete implementation as it's done here because it makes it clear that this really does need to be the wrapper for proper uniqueness comparison. It guarantees at compile tme that if someone changes the below logic to populate some other type of DeleteFile that we're doing something wrong.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "singhpk234 (via GitHub)" <gi...@apache.org>.
singhpk234 commented on PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#issuecomment-5226777439

   Thanks for the work @williamhyun, lets wait for a working day more for @nastra to get back


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "williamhyun (via GitHub)" <gi...@apache.org>.
williamhyun commented on PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#issuecomment-5259922863

   Thanks @singhpk234 @amogh-jahagirdar @nastra for the reviews, I will be cherry-picking to 1.11 branch.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3708583542


##########
core/src/main/java/org/apache/iceberg/rest/TableScanResponseParser.java:
##########


Review Comment:
   Yeah that should be good, not needed in this PR



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "williamhyun (via GitHub)" <gi...@apache.org>.
williamhyun commented on PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#issuecomment-5183456123

   Hi @nastra thank you for the comments, I have included a new test set for `DeleteFileWrapper`
   It would be great if you could take another look at these changes! 


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3726912060


##########
core/src/test/java/org/apache/iceberg/util/TestDeleteFileWrapper.java:
##########
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.util;
+
+import static org.apache.iceberg.TestBase.FILE_A_DELETES;
+import static org.apache.iceberg.TestBase.FILE_B_DELETES;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.iceberg.DeleteFile;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.FileMetadata;
+import org.apache.iceberg.PartitionSpec;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Testing {@link DeleteFileWrapper} is easier in iceberg-core since the delete file builders are
+ * located here
+ */
+public class TestDeleteFileWrapper {
+
+  // TestBase does not provide two deletion vectors at the same location which is required to
+  // exercise the content offset/size identity, so build them locally.
+  private static DeleteFile dv(String path, long contentOffset, long contentSizeInBytes) {
+    return FileMetadata.deleteFileBuilder(PartitionSpec.unpartitioned())
+        .ofPositionDeletes()
+        .withPath(path)
+        .withFormat(FileFormat.PUFFIN)
+        .withFileSizeInBytes(100)
+        .withRecordCount(1)
+        .withReferencedDataFile("/path/to/data.parquet")
+        .withContentOffset(contentOffset)
+        .withContentSizeInBytes(contentSizeInBytes)
+        .build();
+  }
+
+  @Test
+  public void equalsWithSameLocationOffsetAndSize() {
+    // different DeleteFile instances with the same location but differing metadata
+    DeleteFile copy =
+        FileMetadata.deleteFileBuilder(PartitionSpec.unpartitioned())
+            .ofPositionDeletes()
+            .withPath(FILE_A_DELETES.location())
+            .withFileSizeInBytes(1234)
+            .withRecordCount(567)
+            .build();
+
+    DeleteFileWrapper one = DeleteFileWrapper.wrap(FILE_A_DELETES);
+    DeleteFileWrapper two = DeleteFileWrapper.wrap(copy);
+
+    assertThat(one).isEqualTo(two);
+    assertThat(one.hashCode()).isEqualTo(two.hashCode());
+  }
+
+  @Test
+  public void notEqualsWithDifferentLocation() {
+    assertThat(DeleteFileWrapper.wrap(FILE_A_DELETES))
+        .isNotEqualTo(DeleteFileWrapper.wrap(FILE_B_DELETES));
+  }
+
+  @Test
+  public void notEqualsWithSameLocationButDifferentContentOffset() {
+    // two deletion vectors held in the same Puffin file, differing only by content offset
+    DeleteFileWrapper first = DeleteFileWrapper.wrap(dv("/path/to/dv.puffin", 0, 10));
+    DeleteFileWrapper second = DeleteFileWrapper.wrap(dv("/path/to/dv.puffin", 10, 10));
+
+    assertThat(first).isNotEqualTo(second);
+    assertThat(first.hashCode()).isNotEqualTo(second.hashCode());
+  }
+
+  @Test
+  public void notEqualsWithSameLocationButDifferentContentSize() {
+    // two deletion vectors held in the same Puffin file, differing only by content size
+    DeleteFileWrapper first = DeleteFileWrapper.wrap(dv("/path/to/dv.puffin", 0, 10));
+    DeleteFileWrapper second = DeleteFileWrapper.wrap(dv("/path/to/dv.puffin", 0, 20));
+
+    assertThat(first).isNotEqualTo(second);
+    assertThat(first.hashCode()).isNotEqualTo(second.hashCode());
+  }
+
+  @Test
+  public void set() {
+    DeleteFileWrapper wrapper = DeleteFileWrapper.wrap(FILE_A_DELETES);
+    assertThat(wrapper.get()).isEqualTo(FILE_A_DELETES);
+    assertThat(wrapper).isEqualTo(DeleteFileWrapper.wrap(FILE_A_DELETES));
+
+    // set returns the same wrapper, allowing reuse for lookups
+    assertThat(wrapper.set(FILE_B_DELETES)).isSameAs(wrapper);
+    assertThat(wrapper.get()).isEqualTo(FILE_B_DELETES);
+    assertThat(wrapper).isEqualTo(DeleteFileWrapper.wrap(FILE_B_DELETES));
+    assertThat(wrapper.hashCode()).isEqualTo(DeleteFileWrapper.wrap(FILE_B_DELETES).hashCode());
+  }
+
+  @Test
+  public void toStringReturnsLocation() {
+    assertThat(DeleteFileWrapper.wrap(FILE_A_DELETES)).hasToString(FILE_A_DELETES.location());
+  }
+
+  @Test
+  public void notEqualsWithNonWrapper() {
+    assertThat(DeleteFileWrapper.wrap(FILE_A_DELETES)).isNotEqualTo(FILE_A_DELETES);
+  }
+
+  @Test
+  public void notEqualsWithNull() {
+    assertThat(DeleteFileWrapper.wrap(FILE_A_DELETES)).isNotEqualTo(null);

Review Comment:
   .isNotNull()



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "williamhyun (via GitHub)" <gi...@apache.org>.
williamhyun commented on PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#issuecomment-5172574459

   Thank you @singhpk234 and @amogh-jahagirdar for the comments! 


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "williamhyun (via GitHub)" <gi...@apache.org>.
williamhyun commented on PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#issuecomment-5169625234

   cc: @singhpk234 


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Core, REST: Fix delete file references for DVs in the same Puffin file [iceberg]

Posted by "williamhyun (via GitHub)" <gi...@apache.org>.
williamhyun commented on code in PR #17497:
URL: https://github.com/apache/iceberg/pull/17497#discussion_r3716432181


##########
core/src/test/java/org/apache/iceberg/util/TestDeleteFileWrapper.java:
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.util;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.iceberg.DeleteFile;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.FileMetadata;
+import org.apache.iceberg.PartitionSpec;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Testing {@link DeleteFileWrapper} is easier in iceberg-core since the delete file builders are
+ * located here
+ */
+public class TestDeleteFileWrapper {
+
+  private static final DeleteFile FILE_A_DELETES =
+      FileMetadata.deleteFileBuilder(PartitionSpec.unpartitioned())
+          .ofPositionDeletes()
+          .withPath("/path/to/data-a-deletes.parquet")
+          .withFileSizeInBytes(1)
+          .withRecordCount(1)
+          .build();
+  private static final DeleteFile FILE_B_DELETES =
+      FileMetadata.deleteFileBuilder(PartitionSpec.unpartitioned())
+          .ofPositionDeletes()
+          .withPath("/path/to/data-b-deletes.parquet")
+          .withFileSizeInBytes(2)
+          .withRecordCount(2)
+          .build();
+
+  private static DeleteFile dv(String path, long contentOffset, long contentSizeInBytes) {
+    return FileMetadata.deleteFileBuilder(PartitionSpec.unpartitioned())
+        .ofPositionDeletes()
+        .withPath(path)
+        .withFormat(FileFormat.PUFFIN)
+        .withFileSizeInBytes(100)
+        .withRecordCount(1)
+        .withReferencedDataFile("/path/to/data.parquet")
+        .withContentOffset(contentOffset)
+        .withContentSizeInBytes(contentSizeInBytes)
+        .build();
+  }

Review Comment:
   Great suggestion, fixed to reuse TestBase delete file fixtures. 



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org