Jackie-Jiang commented on code in PR #11258: URL: https://github.com/apache/pinot/pull/11258#discussion_r1334897395
########## pinot-common/src/main/java/org/apache/pinot/common/function/DateTimePatternHandler.java: ########## @@ -35,15 +35,33 @@ 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); + } + + public static long parseDateTimeStringToEpochMillis(String dateTimeString, String pattern, String timezoneId, + long defaultVal) { + DateTimeFormatter dateTimeFormatter = getDateTimeFormatter(pattern, timezoneId); Review Comment: Need to have a try-catch over `getDateTimeFormatter` as well ########## pinot-common/src/main/java/org/apache/pinot/common/function/DateTimePatternHandler.java: ########## @@ -35,15 +35,33 @@ 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); + } + + public static long parseDateTimeStringToEpochMillis(String dateTimeString, String pattern, String timezoneId, + long defaultVal) { + DateTimeFormatter dateTimeFormatter = getDateTimeFormatter(pattern, timezoneId); + return parseMillis(dateTimeString, dateTimeFormatter, defaultVal); + } + + private static long parseMillis(String dateTimeString, DateTimeFormatter dateTimeFormatter) { + return parseMillis(dateTimeString, dateTimeFormatter, 0L); Review Comment: We should directly throw exception instead of returning 0. Using implicit default value can case unexpected behavior -- 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