morrySnow commented on code in PR #39482:
URL: https://github.com/apache/doris/pull/39482#discussion_r1722914625
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/TimeRoundSeries.java:
##########
@@ -104,22 +104,27 @@ private static LocalDateTime getDateCeilOrFloor(DATE tag,
LocalDateTime date, in
if (getCeil) {
step = step + (deltaInsidePeriod == 0 ? 0 : period);
}
- switch (tag) {
- case YEAR:
- return ((DateTimeLiteral)
start.plusYears(step)).toJavaDateType();
- case MONTH:
- return ((DateTimeLiteral)
start.plusMonths(step)).toJavaDateType();
- case DAY:
- return ((DateTimeLiteral)
start.plusDays(step)).toJavaDateType();
- case HOUR:
- return ((DateTimeLiteral)
start.plusHours(step)).toJavaDateType();
- case MINUTE:
- return ((DateTimeLiteral)
start.plusMinutes(step)).toJavaDateType();
- case SECOND:
- return ((DateTimeLiteral)
start.plusSeconds(step)).toJavaDateType();
- default:
- break;
+ try {
+ switch (tag) {
+ case YEAR:
+ return ((DateTimeLiteral)
start.plusYears(step)).toJavaDateType();
+ case MONTH:
+ return ((DateTimeLiteral)
start.plusMonths(step)).toJavaDateType();
+ case DAY:
+ return ((DateTimeLiteral)
start.plusDays(step)).toJavaDateType();
+ case HOUR:
+ return ((DateTimeLiteral)
start.plusHours(step)).toJavaDateType();
+ case MINUTE:
+ return ((DateTimeLiteral)
start.plusMinutes(step)).toJavaDateType();
+ case SECOND:
+ return ((DateTimeLiteral)
start.plusSeconds(step)).toJavaDateType();
+ default:
+ break;
+ }
+ } catch (Exception ex) {
+ // do nothing
Review Comment:
exception is expensive, could we process it without try catch
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java:
##########
@@ -336,7 +336,7 @@ protected boolean checkDate() {
}
protected static boolean isDateOutOfRange(LocalDateTime dateTime) {
- return dateTime.isBefore(START_OF_A_DAY) ||
dateTime.isAfter(END_OF_A_DAY);
+ return dateTime.isBefore(START_OF_A_DAY) ||
dateTime.isAfter(END_OF_A_DAY) || dateTime == null;
Review Comment:
```suggestion
return dateTime == null || dateTime.isBefore(START_OF_A_DAY) ||
dateTime.isAfter(END_OF_A_DAY);
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]