Search in sources :

Example 11 with StrConstant

use of io.questdb.griffin.engine.functions.constants.StrConstant in project questdb by bluestreak01.

the class CastByteToStrFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    Function intFunc = args.getQuick(0);
    if (intFunc.isConstant()) {
        StringSink sink = Misc.getThreadLocalBuilder();
        sink.put(intFunc.getByte(null));
        return new StrConstant(Chars.toString(sink));
    }
    return new Func(args.getQuick(0));
}
Also used : UnaryFunction(io.questdb.griffin.engine.functions.UnaryFunction) Function(io.questdb.cairo.sql.Function) StrFunction(io.questdb.griffin.engine.functions.StrFunction) StringSink(io.questdb.std.str.StringSink) StrConstant(io.questdb.griffin.engine.functions.constants.StrConstant)

Example 12 with StrConstant

use of io.questdb.griffin.engine.functions.constants.StrConstant in project questdb by bluestreak01.

the class CastDateToStrFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    Function func = args.getQuick(0);
    if (func.isConstant()) {
        StringSink sink = Misc.getThreadLocalBuilder();
        sink.put(func.getDate(null));
        return new StrConstant(Chars.toString(sink));
    }
    return new Func(args.getQuick(0));
}
Also used : Function(io.questdb.cairo.sql.Function) StrFunction(io.questdb.griffin.engine.functions.StrFunction) UnaryFunction(io.questdb.griffin.engine.functions.UnaryFunction) StringSink(io.questdb.std.str.StringSink) StrConstant(io.questdb.griffin.engine.functions.constants.StrConstant)

Aggregations

StrConstant (io.questdb.griffin.engine.functions.constants.StrConstant)12 StringSink (io.questdb.std.str.StringSink)11 Function (io.questdb.cairo.sql.Function)10 StrFunction (io.questdb.griffin.engine.functions.StrFunction)10 UnaryFunction (io.questdb.griffin.engine.functions.UnaryFunction)10 DateFormat (io.questdb.std.datetime.DateFormat)2 BuildInformation (io.questdb.BuildInformation)1