leonardBang commented on a change in pull request #17749:
URL: https://github.com/apache/flink/pull/17749#discussion_r754769569



##########
File path: 
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/filesystem/DefaultPartTimeExtractor.java
##########
@@ -77,29 +79,49 @@
                     .toFormatter()
                     .withResolverStyle(ResolverStyle.LENIENT);
 
-    @Nullable private final String pattern;
+    @Nullable private final String extractorPattern;
+    @Nullable private final String formatterPattern;
 
-    public DefaultPartTimeExtractor(@Nullable String pattern) {
-        this.pattern = pattern;
+    public DefaultPartTimeExtractor(
+            @Nullable String extractorPattern, @Nullable String 
formatterPattern) {
+        this.extractorPattern = extractorPattern;
+        this.formatterPattern = formatterPattern;
     }
 
     @Override
     public LocalDateTime extract(List<String> partitionKeys, List<String> 
partitionValues) {
         String timestampString;
-        if (pattern == null) {
+        if (extractorPattern == null) {
             timestampString = partitionValues.get(0);
         } else {
-            timestampString = pattern;
+            timestampString = extractorPattern;
             for (int i = 0; i < partitionKeys.size(); i++) {
                 timestampString =
                         timestampString.replaceAll(
                                 "\\$" + partitionKeys.get(i), 
partitionValues.get(i));
             }
         }
-        return toLocalDateTime(timestampString);
+        return toLocalDateTime(timestampString, this.formatterPattern);
     }
 
-    public static LocalDateTime toLocalDateTime(String timestampString) {
+    public static LocalDateTime toLocalDateTime(
+            String timestampString, @Nullable String formatterPattern) {
+
+        if (formatterPattern == null) {
+            return 
DefaultPartTimeExtractor.toLocalDateTimeDefault(timestampString);
+        }

Review comment:
       we can give the default formatterPattern when the `formatterPattern` is 
`NULL`, and then we can remove `toLocalDateTimeDefault` method safely.
   
   ```java
   
          DateTimeFormatter dateTimeFormatter =
                   formatterPattern == null
                           ? TIMESTAMP_FORMATTER
                           : DateTimeFormatter.ofPattern(formatterPattern, 
Locale.ROOT);
   
   ```




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