This is an automated email from the ASF dual-hosted git repository.
liulijia 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 866814d [Improve] Add FE function `timestamp` (#6339)
866814d is described below
commit 866814dc4740f8486123e6579b5ed2920107dca4
Author: Wang Shuo <[email protected]>
AuthorDate: Wed Aug 4 11:52:46 2021 +0800
[Improve] Add FE function `timestamp` (#6339)
* Add FE function timestamp
---
.../src/main/java/org/apache/doris/rewrite/FEFunctions.java | 8 ++++++++
.../test/java/org/apache/doris/planner/ConstantExpressTest.java | 6 ++++++
2 files changed, 14 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
index d67c55c..03150ba 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
@@ -317,6 +317,14 @@ public class FEFunctions {
return null;
}
+ @FEFunction(name = "timestamp", argTypes = {"DATETIME"}, returnType =
"DATETIME")
+ public static DateLiteral timestamp(LiteralExpr arg) throws
AnalysisException {
+ if (arg instanceof DateLiteral) {
+ return (DateLiteral) arg;
+ }
+ return null;
+ }
+
/**
------------------------------------------------------------------------------
*/
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/planner/ConstantExpressTest.java
b/fe/fe-core/src/test/java/org/apache/doris/planner/ConstantExpressTest.java
index 4bcaea3..5e30942 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/ConstantExpressTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/ConstantExpressTest.java
@@ -225,4 +225,10 @@ public class ConstantExpressTest {
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext,
"explain " + sql);
Assert.assertTrue(explainString.contains("NULL"));
}
+
+ @Test
+ public void testTimestamp() throws Exception {
+ testConstantExpressResult("select timestamp('2021-07-24 00:00:00')",
+ "'2021-07-24 00:00:00'");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]