You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/07/29 21:44:45 UTC

[GitHub] [hudi] yihua commented on a diff in pull request #6250: [HUDI-4507] Improve file name extraction logic in metadata utils

yihua commented on code in PR #6250:
URL: https://github.com/apache/hudi/pull/6250#discussion_r933634375


##########
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java:
##########
@@ -1162,13 +1154,8 @@ private static Stream<HoodieRecord> getColumnStatsRecords(String partitionPath,
                                                             HoodieTableMetaClient datasetMetaClient,
                                                             List<String> columnsToIndex,
                                                             boolean isDeleted) {
-    String partitionName = getPartitionIdentifier(partitionPath);
-    // NOTE: We have to chop leading "/" to make sure Hadoop does not treat it like
-    //       absolute path
     String filePartitionPath = filePath.startsWith("/") ? filePath.substring(1) : filePath;
-    String fileName = partitionName.equals(NON_PARTITIONED_NAME)
-        ? filePartitionPath
-        : filePartitionPath.substring(partitionName.length() + 1);
+    String fileName = FSUtils.getFileName(filePath, partitionPath);

Review Comment:
   The same here, using `partitionPath` directly instead of the partition identified.



##########
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java:
##########
@@ -325,16 +325,13 @@ public static List<HoodieRecord> convertMetadataToFilesPartitionRecords(HoodieCo
                           return map;
                         }
 
-                        int offset = partition.equals(NON_PARTITIONED_NAME)
-                            ? (pathWithPartition.startsWith("/") ? 1 : 0)
-                            : partition.length() + 1;
-                        String filename = pathWithPartition.substring(offset);
+                        String fileName = FSUtils.getFileName(pathWithPartition, partitionStatName);

Review Comment:
   Before the change, the `partition` identifier is used, instead of `partitionStatName`.  For a partitioned table, there is no difference; for a non-partitioned table, the `partition` identifier is `.` while `partitionStatName` could be empty or `/`.  The new logic depends on `partitionStatName` instead of `partition` identified, and the file name extracted is not affected.



-- 
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: commits-unsubscribe@hudi.apache.org

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