This is an automated email from the ASF dual-hosted git repository.
zhaoc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 41f1ab0 Add curdate/now function in fe (#3215)
41f1ab0 is described below
commit 41f1ab006bd15b4bad1bc20bcad7d6c6543e8f07
Author: HangyuanLiu <[email protected]>
AuthorDate: Sat Mar 28 13:39:54 2020 +0800
Add curdate/now function in fe (#3215)
---
fe/src/main/java/org/apache/doris/rewrite/FEFunctions.java | 12 ++++++++++++
.../java/org/apache/doris/planner/ConstantExpressTest.java | 8 ++++++++
2 files changed, 20 insertions(+)
diff --git a/fe/src/main/java/org/apache/doris/rewrite/FEFunctions.java
b/fe/src/main/java/org/apache/doris/rewrite/FEFunctions.java
index a806042..30f6fb4 100755
--- a/fe/src/main/java/org/apache/doris/rewrite/FEFunctions.java
+++ b/fe/src/main/java/org/apache/doris/rewrite/FEFunctions.java
@@ -33,6 +33,8 @@ import com.google.common.base.Preconditions;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.joda.time.DateTimeZone;
+import org.joda.time.LocalDateTime;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -210,6 +212,16 @@ public class FEFunctions {
return new StringLiteral(dl.dateFormat(fmtLiteral.getStringValue()));
}
+ @FEFunction(name = "now", argTypes = {}, returnType = "DATETIME")
+ public static DateLiteral now() throws AnalysisException {
+ return new
DateLiteral(LocalDateTime.now(DateTimeZone.forTimeZone(TimeUtils.getTimeZone())),
Type.DATETIME);
+ }
+
+ @FEFunction(name = "curdate", argTypes = {}, returnType = "DATE")
+ public static DateLiteral curDate() throws AnalysisException {
+ return new
DateLiteral(LocalDateTime.now(DateTimeZone.forTimeZone(TimeUtils.getTimeZone())),
Type.DATE);
+ }
+
/**
------------------------------------------------------------------------------
*/
diff --git a/fe/src/test/java/org/apache/doris/planner/ConstantExpressTest.java
b/fe/src/test/java/org/apache/doris/planner/ConstantExpressTest.java
index c5365b8..3d1f6c9 100644
--- a/fe/src/test/java/org/apache/doris/planner/ConstantExpressTest.java
+++ b/fe/src/test/java/org/apache/doris/planner/ConstantExpressTest.java
@@ -101,6 +101,14 @@ public class ConstantExpressTest {
testConstantExpressResult(
"select UNIX_TIMESTAMP(\"1970-01-01 08:00:01\");",
"1");
+
+ testConstantExpressResult(
+ "select now();",
+ "");
+
+ testConstantExpressResult(
+ "select curdate();",
+ "");
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]