[Improve] Add FE function timestamp (#6339)
* Add FE function timestamp
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@ -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'");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user