JingsongLi commented on a change in pull request #10268: 
[Flink-14599][table-planner-blink] Support precision of TimestampType in blink 
planner
URL: https://github.com/apache/flink/pull/10268#discussion_r349444341
 
 

 ##########
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java
 ##########
 @@ -205,6 +214,36 @@ public static long toTimestamp(Decimal v) {
        // 
--------------------------------------------------------------------------------------------
        // String --> Timestamp conversion
        // 
--------------------------------------------------------------------------------------------
+       public static SqlTimestamp toSqlTimestamp(String dateStr) {
+               int length = dateStr.length();
+               String format;
+               if (length == 10) {
+                       format = DATE_FORMAT_STRING;
+               } else if (length >= 21 && length <= 29) {
+                       format = DEFAULT_DATETIME_FORMATS[length - 20];
+               } else {
+                       // otherwise fall back to second's precision
+                       format = DEFAULT_DATETIME_FORMATS[0];
+               }
+               return toSqlTimestamp(dateStr, format);
+       }
+
+       public static SqlTimestamp toSqlTimestamp(String dateStr, String 
format) {
+               DateTimeFormatter formatter = 
DateTimeFormatter.ofPattern(format);
 
 Review comment:
   `DateTimeFormatter.ofPattern` is very expensive performance, please add 
cache like previous `FORMATTER_CACHE`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to