You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/06/13 09:42:05 UTC

[doris] branch master updated: [Fix](Nereids) constant folding for function timestamp() (#20607)

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

morrysnow 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 0e82c0d7a2 [Fix](Nereids) constant folding for function timestamp() (#20607)
0e82c0d7a2 is described below

commit 0e82c0d7a217ba1b15a7752c4b4d0bd35402823b
Author: mch_ucchi <41...@users.noreply.github.com>
AuthorDate: Tue Jun 13 17:41:58 2023 +0800

    [Fix](Nereids) constant folding for function timestamp() (#20607)
---
 .../functions/executable/DateTimeExtractAndTransform.java  | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
index b0a61832b6..1872a2b19d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
@@ -294,9 +294,9 @@ public class DateTimeExtractAndTransform {
         return new DateLiteral(dateTime.getYear(), dateTime.getMonth(), dateTime.getDay());
     }
 
-    @ExecFunction(name = "date", argTypes = {"DATETIMEV2"}, returnType = "DATE")
+    @ExecFunction(name = "date", argTypes = {"DATETIMEV2"}, returnType = "DATEV2")
     public static Expression date(DateTimeV2Literal dateTime) throws AnalysisException {
-        return new DateLiteral(dateTime.getYear(), dateTime.getMonth(), dateTime.getDay());
+        return new DateV2Literal(dateTime.getYear(), dateTime.getMonth(), dateTime.getDay());
     }
 
     /**
@@ -563,4 +563,14 @@ public class DateTimeExtractAndTransform {
         return DateTimeLiteral.fromJavaDateType(DateUtils.getTime(DateUtils.formatBuilder(format.getValue())
                         .toFormatter(), str.getValue()));
     }
+
+    @ExecFunction(name = "timestamp", argTypes = {"DATETIME"}, returnType = "DATETIME")
+    public static Expression timestamp(DateTimeLiteral datetime) {
+        return datetime;
+    }
+
+    @ExecFunction(name = "timestamp", argTypes = {"DATETIMEV2"}, returnType = "DATETIMEV2")
+    public static Expression timestamp(DateTimeV2Literal datetime) {
+        return datetime;
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org