flyrain commented on code in PR #11555:
URL: https://github.com/apache/iceberg/pull/11555#discussion_r1904432648


##########
core/src/main/java/org/apache/iceberg/io/DeleteSchemaUtil.java:
##########
@@ -43,4 +43,15 @@ public static Schema pathPosSchema() {
   public static Schema posDeleteSchema(Schema rowSchema) {
     return rowSchema == null ? pathPosSchema() : pathPosSchema(rowSchema);
   }
+
+  public static Schema posDeleteReadSchema(Schema rowSchema) {

Review Comment:
   This might not directly related to this PR, but seems like the column `row` 
should NOT be marked as `required` anywhere. 



##########
core/src/main/java/org/apache/iceberg/util/ContentFileUtil.java:
##########
@@ -60,28 +69,63 @@ public static CharSequence referencedDataFile(DeleteFile 
deleteFile) {
       return deleteFile.referencedDataFile();
     }
 
-    int pathId = MetadataColumns.DELETE_FILE_PATH.fieldId();
-    Type pathType = MetadataColumns.DELETE_FILE_PATH.type();
-
     Map<Integer, ByteBuffer> lowerBounds = deleteFile.lowerBounds();
-    ByteBuffer lowerPathBound = lowerBounds != null ? lowerBounds.get(pathId) 
: null;
+    ByteBuffer lowerPathBound = lowerBounds != null ? lowerBounds.get(PATH_ID) 
: null;
     if (lowerPathBound == null) {
       return null;
     }
 
     Map<Integer, ByteBuffer> upperBounds = deleteFile.upperBounds();
-    ByteBuffer upperPathBound = upperBounds != null ? upperBounds.get(pathId) 
: null;
+    ByteBuffer upperPathBound = upperBounds != null ? upperBounds.get(PATH_ID) 
: null;
     if (upperPathBound == null) {
       return null;
     }
 
     if (lowerPathBound.equals(upperPathBound)) {
-      return Conversions.fromByteBuffer(pathType, lowerPathBound);
+      return Conversions.fromByteBuffer(PATH_TYPE, lowerPathBound);
     } else {
       return null;
     }
   }
 
+  /**
+   * Replace file_path reference for a delete file entry
+   *
+   * @param deleteFile delete file whose entry will be replaced
+   * @param sourcePrefix source prefix which will be replaced
+   * @param targetPrefix target prefix which will replace it
+   * @return metrics for the new delete file entry
+   */
+  public static Metrics replacePathBounds(
+      DeleteFile deleteFile, String sourcePrefix, String targetPrefix) {
+    Preconditions.checkArgument(
+        deleteFile.content() == FileContent.POSITION_DELETES,
+        "Only position delete files supported");
+
+    Map<Integer, ByteBuffer> lowerBounds = deleteFile.lowerBounds();
+    ByteBuffer lowerPathBound = lowerBounds != null ? lowerBounds.get(PATH_ID) 
: null;
+    if (lowerPathBound == null) {
+      return metricsWithoutPathBounds(deleteFile);
+    }
+
+    Map<Integer, ByteBuffer> upperBounds = deleteFile.upperBounds();
+    ByteBuffer upperPathBound = upperBounds != null ? upperBounds.get(PATH_ID) 
: null;
+    if (upperPathBound == null) {
+      return metricsWithoutPathBounds(deleteFile);
+    }
+
+    if (lowerPathBound.equals(upperPathBound)) {

Review Comment:
   I think it's worth to have a comment to clarify the behavior. It isn't a 
blocker to me though. 



##########
core/src/main/java/org/apache/iceberg/io/DeleteSchemaUtil.java:
##########
@@ -43,4 +43,15 @@ public static Schema pathPosSchema() {
   public static Schema posDeleteSchema(Schema rowSchema) {
     return rowSchema == null ? pathPosSchema() : pathPosSchema(rowSchema);
   }
+
+  public static Schema posDeleteReadSchema(Schema rowSchema) {
+    return new Schema(
+        MetadataColumns.DELETE_FILE_PATH,
+        MetadataColumns.DELETE_FILE_POS,
+        Types.NestedField.optional(
+            MetadataColumns.DELETE_FILE_ROW_FIELD_ID,
+            "row",

Review Comment:
   could we reuse this constant `DELETE_FILE_ROW_FIELD_NAME`?



-- 
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-unsubscr...@iceberg.apache.org

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


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

Reply via email to