linrrzqqq commented on code in PR #64127:
URL: https://github.com/apache/doris/pull/64127#discussion_r3366869957
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeArithmetic.java:
##########
@@ -879,26 +878,31 @@ public static Expression
milliSecondsSub(TimestampTzLiteral date, BigIntLiteral
*/
@ExecFunction(name = "datediff")
public static Expression dateDiff(DateV2Literal date1, DateV2Literal
date2) {
- return new IntegerLiteral(dateDiff(date1.toJavaDateType(),
date2.toJavaDateType()));
+ return dateDiff((DateLiteral) date1, date2);
}
@ExecFunction(name = "datediff")
public static Expression dateDiff(DateV2Literal date1, DateTimeV2Literal
date2) {
- return new IntegerLiteral(dateDiff(date1.toJavaDateType(),
date2.toJavaDateType()));
+ return dateDiff((DateLiteral) date1, date2);
}
@ExecFunction(name = "datediff")
public static Expression dateDiff(DateTimeV2Literal date1, DateV2Literal
date2) {
- return new IntegerLiteral(dateDiff(date1.toJavaDateType(),
date2.toJavaDateType()));
+ return dateDiff((DateLiteral) date1, date2);
}
@ExecFunction(name = "datediff")
public static Expression dateDiff(DateTimeV2Literal date1,
DateTimeV2Literal date2) {
- return new IntegerLiteral(dateDiff(date1.toJavaDateType(),
date2.toJavaDateType()));
+ return dateDiff((DateLiteral) date1, date2);
}
- private static int dateDiff(LocalDateTime date1, LocalDateTime date2) {
- return ((int) ChronoUnit.DAYS.between(date2.toLocalDate(),
date1.toLocalDate()));
Review Comment:
ChronoUnit 认为0000 年 2 月是闰年,但是我们内部的行为应该是认为0000年是平年, 所以常量折叠如果覆盖到了 0000.2,
就会多一天出来
--
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]