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


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/cluster/strategy/PartitionAwareClusteringPlanStrategy.java:
##########
@@ -102,15 +102,23 @@ protected Pair<Stream<HoodieClusteringGroup>, Boolean> 
buildClusteringGroupsForP
     }
 
     if (!currentGroup.isEmpty()) {
-      if (currentGroup.size() > 1 || 
writeConfig.shouldClusteringSingleGroup()) {
-        int numOutputGroups = getNumberOfOutputFileGroups(totalSizeSoFar, 
writeConfig.getClusteringTargetFileMaxBytes());
-        log.info("Adding final clustering group " + totalSizeSoFar + " max 
bytes: "
-            + writeConfig.getClusteringMaxBytesInGroup() + " num input slices: 
" + currentGroup.size() + " output groups: " + numOutputGroups);
-        fileSliceGroups.add(Pair.of(currentGroup, numOutputGroups));
-      }
+      int numOutputGroups = getNumberOfOutputFileGroups(totalSizeSoFar, 
writeConfig.getClusteringTargetFileMaxBytes());
+      log.info("Adding final clustering group " + totalSizeSoFar + " max 
bytes: "
+          + writeConfig.getClusteringMaxBytesInGroup() + " num input slices: " 
+ currentGroup.size() + " output groups: " + numOutputGroups);
+      fileSliceGroups.add(Pair.of(currentGroup, numOutputGroups));
     }
 
-    return Pair.of(fileSliceGroups.stream().map(fileSliceGroup ->
+    return Pair.of(fileSliceGroups.stream().filter(fileSliceGroup -> {
+      if (fileSliceGroup.getLeft().size() == 1 && fileSliceGroup.getRight() == 
1 && !writeConfig.isSingleGroupClusteringEnabled()) {
+        FileSlice targetedFileSlice = fileSliceGroup.getLeft().get(0);
+        long size = targetedFileSlice.getBaseFile().isPresent() ? 
targetedFileSlice.getBaseFile().get().getFileSize() : 
writeConfig.getParquetMaxFileSize();

Review Comment:
   This checks `isSingleGroupClusteringEnabled()` but the original code used 
`shouldClusteringSingleGroup()`, which also returns true when sort columns are 
configured (`isClusteringSortEnabled()`). With this change, if a user has sort 
columns set but `single.group.clustering.enabled=false`, we'd skip clustering a 
single file — but sorting a single file into a different layout is still a 
meaningful operation. Is this new behavior intended?



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

Reply via email to