EricJoy2048 commented on code in PR #6601:
URL: https://github.com/apache/seatunnel/pull/6601#discussion_r1554843270


##########
seatunnel-formats/seatunnel-format-text/src/main/java/org/apache/seatunnel/format/text/TextDeserializationSchema.java:
##########
@@ -235,21 +242,39 @@ private Object convert(String field, SeaTunnelDataType<?> 
fieldType, int level)
             case BYTES:
                 return field.getBytes(StandardCharsets.UTF_8);
             case DATE:
-                return DateUtils.parse(field, dateFormatter);
+                DateTimeFormatter dateFormatter = 
fieldFormatterMap.get(fieldName);
+                if (dateFormatter == null) {
+                    dateFormatter = DateUtils.matchDateTimeFormatter(field);
+                    fieldFormatterMap.put(fieldName, dateFormatter);
+                }
+
+                return 
dateFormatter.parse(field).query(TemporalQueries.localDate());
             case TIME:
-                return TimeUtils.parse(field, timeFormatter);
+                TemporalAccessor parsedTime = TIME_FORMAT.parse(field);
+                return parsedTime.query(TemporalQueries.localTime());
             case TIMESTAMP:

Review Comment:
   > Why change this logic? What are the benefits?
   
   `TimeUtils.parse(field, timeFormatter)` have the best performance, but only 
can parse `HH:mm:ss` format.
   
   I replace it with a format can parse `HH:mm:ss` between 
`HH:mm:ss.SSSSSSSSS`, support `0` to `9` length nano of second. 
   
   
   
   ```
   public static final DateTimeFormatter TIME_FORMAT =
               new DateTimeFormatterBuilder()
                       .appendPattern("HH:mm:ss")
                       .appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true)
                       .toFormatter();
   ```
   



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