szehon-ho commented on code in PR #11555: URL: https://github.com/apache/iceberg/pull/11555#discussion_r1905120821
########## 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: Done ########## 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: Done -- 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