This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/dev-1.1.2 by this push:
     new f67af7628d [Bug](function) fix current_date not equal to curdate 
(#11463) (#11491)
f67af7628d is described below

commit f67af7628d2ba8fac847bc89cb37dce435ecbe2c
Author: yiguolei <[email protected]>
AuthorDate: Thu Aug 4 10:30:11 2022 +0800

    [Bug](function) fix current_date not equal to curdate (#11463) (#11491)
    
    * fix current_date not equal to curdate
    
    Co-authored-by: Pxl <[email protected]>
---
 be/src/vec/runtime/vdatetime_value.cpp                        |  5 +++++
 .../src/main/java/org/apache/doris/analysis/DateLiteral.java  | 11 +++++++----
 fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java  |  2 +-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/be/src/vec/runtime/vdatetime_value.cpp 
b/be/src/vec/runtime/vdatetime_value.cpp
index 97cec16e0f..fc2a93e6b6 100644
--- a/be/src/vec/runtime/vdatetime_value.cpp
+++ b/be/src/vec/runtime/vdatetime_value.cpp
@@ -287,6 +287,11 @@ void VecDateTimeValue::set_zero(int type) {
 
 void VecDateTimeValue::set_type(int type) {
     _type = type;
+    if (type == TIME_DATE) {
+        _hour = 0;
+        _minute = 0;
+        _second = 0;
+    }
 }
 
 void VecDateTimeValue::set_max_time(bool neg) {
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 9f5956bc90..2e84db246a 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
@@ -233,10 +233,13 @@ public class DateLiteral extends LiteralExpr {
         this.year = dateTime.getYear();
         this.month = dateTime.getMonthOfYear();
         this.day = dateTime.getDayOfMonth();
-        this.hour = dateTime.getHourOfDay();
-        this.minute = dateTime.getMinuteOfHour();
-        this.second = dateTime.getSecondOfMinute();
-        this.type = type;                                                      
      
+        this.type = type;
+        if (type.equals(Type.DATETIME)) {
+            this.hour = dateTime.getHour();
+            this.minute = dateTime.getMinute();
+            this.second = dateTime.getSecond();
+            this.microsecond = dateTime.get(ChronoField.MICRO_OF_SECOND);
+        }
     }
 
     public DateLiteral(DateLiteral other) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
index c393329288..850bf8be43 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
@@ -720,7 +720,7 @@ abstract public class Expr extends TreeNode<Expr> 
implements ParseNode, Cloneabl
         try {
             return trySubstituteList(exprs, smap, analyzer, preserveRootTypes);
         } catch (Exception e) {
-            throw new IllegalStateException("Failed analysis after expr 
substitution.", e);
+            throw new IllegalStateException("Failed analysis after expr 
substitution: " + e.getMessage());
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to