Search in sources :

Example 1 with SysdateFunctionFactory

use of io.questdb.griffin.engine.functions.date.SysdateFunctionFactory 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)

Example 2 with SysdateFunctionFactory

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

the class FunctionParserTest method testNoArgFunctionWrongSignature.

@Test
public void testNoArgFunctionWrongSignature() {
    functions.add(new SysdateFunctionFactory());
    final GenericRecordMetadata metadata = new GenericRecordMetadata();
    metadata.add(new TableColumnMetadata("a", 1, ColumnType.BOOLEAN));
    assertFail(7, "unexpected argument", "a or   sysdate(a)", metadata);
}
Also used : SysdateFunctionFactory(io.questdb.griffin.engine.functions.date.SysdateFunctionFactory) Test(org.junit.Test)

Aggregations

SysdateFunctionFactory (io.questdb.griffin.engine.functions.date.SysdateFunctionFactory)2 Test (org.junit.Test)2 Function (io.questdb.cairo.sql.Function)1 ToStrDateFunctionFactory (io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory)1 NumericException (io.questdb.std.NumericException)1 MillisecondClock (io.questdb.std.datetime.millitime.MillisecondClock)1