DateTimeFunction { private FunctionResolver timestamp() { return define(BuiltinFunctionName.TIMESTAMP.getName(), impl(nullMissingHandling(DateTimeFunction::exprTimestamp), TIMESTAMP, STRING), impl(nullMissingHandling(DateTimeFunction::exprTimestamp), TIMESTAMP, DATE), impl(nullMissingHandling(DateTimeFunction::exprTimestamp), TIMESTAMP, DATETIME), impl(nullMissingHandling(DateTimeFunction::exprTimestamp), TIMESTAMP, TIMESTAMP)); }  void register(BuiltinFunctionRepository repository);  }
@Test public void timestamp() { when(nullRef.type()).thenReturn(TIMESTAMP); when(missingRef.type()).thenReturn(TIMESTAMP); assertEquals(nullValue(), eval(dsl.timestamp(nullRef))); assertEquals(missingValue(), eval(dsl.timestamp(missingRef))); FunctionExpression expr = dsl.timestamp(DSL.literal("2020-08-17 01:01:01")); assertEquals(TIMESTAMP, expr.type()); assertEquals(new ExprTimestampValue("2020-08-17 01:01:01"), expr.valueOf(env)); assertEquals("timestamp(\"2020-08-17 01:01:01\")", expr.toString()); expr = dsl.timestamp(DSL.literal(new ExprTimestampValue("2020-08-17 01:01:01"))); assertEquals(TIMESTAMP, expr.type()); assertEquals(new ExprTimestampValue("2020-08-17 01:01:01"), expr.valueOf(env)); assertEquals("timestamp(TIMESTAMP '2020-08-17 01:01:01')", expr.toString()); }