Search in sources :

Example 6 with ToStrDateFunctionFactory

use of io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory in project questdb by bluestreak01.

the class FunctionParserTest method testNoArgFunction.

@Test
public void testNoArgFunction() throws SqlException {
    functions.add(new SysdateFunctionFactory());
    functions.add(new ToStrDateFunctionFactory());
    FunctionParser functionParser = new FunctionParser(new DefaultCairoConfiguration(root) {

        @Override
        public MillisecondClock getMillisecondClock() {
            return () -> {
                try {
                    return DateFormatUtils.parseUTCDate("2018-03-04T21:40:00.000Z");
                } catch (NumericException e) {
                    Assert.fail();
                }
                return 0;
            };
        }
    }, new FunctionFactoryCache(configuration, functions));
    Function function = parseFunction("to_str(sysdate(), 'EE, dd-MMM-yyyy HH:mm:ss')", new GenericRecordMetadata(), functionParser);
    TestUtils.assertEquals("Sunday, 04-Mar-2018 21:40:00", function.getStr(null));
}
Also used : Function(io.questdb.cairo.sql.Function) SysdateFunctionFactory(io.questdb.griffin.engine.functions.date.SysdateFunctionFactory) ToStrDateFunctionFactory(io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory) NumericException(io.questdb.std.NumericException) MillisecondClock(io.questdb.std.datetime.millitime.MillisecondClock) Test(org.junit.Test)

Aggregations

ToStrDateFunctionFactory (io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory)6 Test (org.junit.Test)6 Function (io.questdb.cairo.sql.Function)5 ToStrTimestampFunctionFactory (io.questdb.griffin.engine.functions.date.ToStrTimestampFunctionFactory)3 Record (io.questdb.cairo.sql.Record)1 SysdateFunctionFactory (io.questdb.griffin.engine.functions.date.SysdateFunctionFactory)1 ToCharBinFunctionFactory (io.questdb.griffin.engine.functions.str.ToCharBinFunctionFactory)1 NumericException (io.questdb.std.NumericException)1 MillisecondClock (io.questdb.std.datetime.millitime.MillisecondClock)1