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