luoyuxia commented on code in PR #22249:
URL: https://github.com/apache/flink/pull/22249#discussion_r1223891576


##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileSystemTableSource.java:
##########
@@ -269,10 +271,35 @@ private SourceProvider 
createSourceProvider(BulkFormat<RowData, FileSourceSplit>
         tableOptions
                 
.getOptional(FileSystemConnectorOptions.SOURCE_MONITOR_INTERVAL)
                 .ifPresent(fileSourceBuilder::monitorContinuously);
+        tableOptions
+                .getOptional(FileSystemConnectorOptions.SOURCE_REGEX_PATTERN)
+                .ifPresent(
+                        s -> {
+                            String regexPath = 
connectBasePathAndRegex(path.getPath(), s);
+                            fileSourceBuilder.setFileEnumerator(
+                                    bulkFormat.isSplittable()
+                                            ? () -> new 
BlockSplittingRegexEnumerator(regexPath)
+                                            : () -> new 
NonSplittingRegexEnumerator(regexPath));
+                        });
 
         return SourceProvider.of(fileSourceBuilder.build());
     }
 
+    private String connectBasePathAndRegex(String basePath, String regex) {
+        StringBuilder result = new StringBuilder();
+        result.append(basePath);
+        if (!basePath.endsWith(Path.SEPARATOR)) {
+            result.append(Path.SEPARATOR);
+        }
+        int startIndex = 0;
+        while (startIndex < regex.length()

Review Comment:
   No, I mean user provide base dir and `source.regex-pattern`. But the 
`source.regex-pattern` should also be absolute path insteading of relative 
path.  But we only serach from the base dir  and to check each file.
   
   Take this for example, `source.regex-pattern` will be `/dir/t/.*/inner/.*` 
which looks more clear than `.*/inner/.*` to me.
   I'm wondering whether use `/dir/t/.*/inner/.*` will be more clear.
   
   
   



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