JingsongLi commented on code in PR #6556:
URL: https://github.com/apache/paimon/pull/6556#discussion_r2509104953


##########
paimon-core/src/main/java/org/apache/paimon/table/format/FormatTableScan.java:
##########
@@ -240,14 +242,58 @@ private List<Split> createSplits(FileIO fileIO, Path 
path, BinaryRow partition)
         FileStatus[] files = fileIO.listFiles(path, true);
         for (FileStatus file : files) {
             if (isDataFileName(file.getPath().getName())) {
-                FormatDataSplit split =
-                        new FormatDataSplit(file.getPath(), 0, file.getLen(), 
partition);
-                splits.add(split);
+                if (isSplittableFile(table.format(), 
file.getPath().getName())) {
+                    List<FormatDataSplit> fileSplits =
+                            splitLargeFile(file, 
coreOptions.splitTargetSize(), partition);
+                    splits.addAll(fileSplits);
+                } else {
+                    splits.add(new FormatDataSplit(file.getPath(), 
file.getLen(), partition));
+                }
             }
         }
         return splits;
     }
 
+    private boolean isSplittableFile(FormatTable.Format format, String 
fileName) {
+        return ((format == FormatTable.Format.CSV
+                                && 
!table.options().containsKey(CsvOptions.LINE_DELIMITER.key()))
+                        || (format == FormatTable.Format.JSON
+                                && 
!table.options().containsKey(JsonOptions.LINE_DELIMITER.key())))
+                && isTextFileUncompressed(fileName);
+    }
+
+    private static boolean isTextFileUncompressed(String fileName) {
+        if (fileName == null || fileName.trim().isEmpty()) {
+            return false;
+        }
+        String[] parts = fileName.split("\\.");
+        if (parts.length < 2) {
+            return false;
+        }
+        String lastExt = parts[parts.length - 1].toLowerCase();
+        return "csv".equals(lastExt) || "json".equals(lastExt);
+    }
+
+    private List<FormatDataSplit> splitLargeFile(
+            FileStatus file, long maxSplitBytes, BinaryRow partition) {
+

Review Comment:
   ```
   if (file.getLen <= maxSplitBytes) {
      return new FormatDataSplit;
   }
   ```



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