[Improve] Add FE function timestamp (#6339)

* Add FE function timestamp
This commit is contained in:
Wang Shuo
2021-08-04 11:52:46 +08:00
committed by GitHub
parent d1007afe80
commit 866814dc47
2 changed files with 14 additions and 0 deletions

View File

@ -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;
}
/**
------------------------------------------------------------------------------
*/

View File

@ -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'");
}
}