You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ga...@apache.org on 2022/12/05 12:34:30 UTC
[doris] branch master updated: [Bug](date function) Fix date_add function (#14826)
This is an automated email from the ASF dual-hosted git repository.
gabriellee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new db4524c10e [Bug](date function) Fix date_add function (#14826)
db4524c10e is described below
commit db4524c10e79c09480f1bda63b7ff8abf38f8cd9
Author: Gabriel <ga...@gmail.com>
AuthorDate: Mon Dec 5 20:34:20 2022 +0800
[Bug](date function) Fix date_add function (#14826)
---
.../java/org/apache/doris/analysis/DateLiteral.java | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java
index 83f4473114..8c2fc20303 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java
@@ -909,14 +909,32 @@ public class DateLiteral extends LiteralExpr {
}
public DateLiteral plusHours(int hour) throws AnalysisException {
+ if (type.isDate()) {
+ return new DateLiteral(getTimeFormatter().plusHours(hour), Type.DATETIME);
+ }
+ if (type.isDateV2()) {
+ return new DateLiteral(getTimeFormatter().plusHours(hour), Type.DATETIMEV2);
+ }
return new DateLiteral(getTimeFormatter().plusHours(hour), type);
}
public DateLiteral plusMinutes(int minute) {
+ if (type.isDate()) {
+ return new DateLiteral(getTimeFormatter().plusMinutes(minute), Type.DATETIME);
+ }
+ if (type.isDateV2()) {
+ return new DateLiteral(getTimeFormatter().plusMinutes(minute), Type.DATETIMEV2);
+ }
return new DateLiteral(getTimeFormatter().plusMinutes(minute), type);
}
public DateLiteral plusSeconds(int second) {
+ if (type.isDate()) {
+ return new DateLiteral(getTimeFormatter().plusSeconds(second), Type.DATETIME);
+ }
+ if (type.isDateV2()) {
+ return new DateLiteral(getTimeFormatter().plusSeconds(second), Type.DATETIMEV2);
+ }
return new DateLiteral(getTimeFormatter().plusSeconds(second), type);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org