walterddr commented on code in PR #11258:
URL: https://github.com/apache/pinot/pull/11258#discussion_r1283397014


##########
pinot-common/src/main/java/org/apache/pinot/common/function/DateTimePatternHandler.java:
##########
@@ -35,15 +35,23 @@ private DateTimePatternHandler() {
    */
   public static long parseDateTimeStringToEpochMillis(String dateTimeString, 
String pattern) {
     DateTimeFormatter dateTimeFormatter = getDateTimeFormatter(pattern);
-    return dateTimeFormatter.parseMillis(dateTimeString);
+    return parseMillis(dateTimeString, dateTimeFormatter);
   }
 
   /**
    * Converts the dateTimeString of passed pattern into a long of the millis 
since epoch
    */
   public static long parseDateTimeStringToEpochMillis(String dateTimeString, 
String pattern, String timezoneId) {
     DateTimeFormatter dateTimeFormatter = getDateTimeFormatter(pattern, 
timezoneId);
-    return dateTimeFormatter.parseMillis(dateTimeString);
+    return parseMillis(dateTimeString, dateTimeFormatter);
+  }
+
+  private static long parseMillis(String dateTimeString, DateTimeFormatter 
dateTimeFormatter) {
+    try {
+      return dateTimeFormatter.parseMillis(dateTimeString);
+    } catch (Exception e) {
+      return 0L;

Review Comment:
   i have concerns on doing this by default. one alternative is to add a 
   ```
   fromDateTime(String dateTimeString, String pattern, long defaultValue)
   ```
   and only allow returning default value when malformed dateTimeString is 
encountered otherwise still throw an exception. please share your thoughts
   
   



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to