Search in sources :

Example 1 with IntConstant

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

the class ClassResolveFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) throws SqlException {
    final Function nameFunction = args.getQuick(0);
    final CharSequence type = args.getQuick(1).getStr(null);
    if (SqlKeywords.isRegclassKeyword(type)) {
        final IntConstant func = map.get(nameFunction.getStr(null));
        if (func != null) {
            return func;
        }
        throw SqlException.$(argPositions.getQuick(0), "unsupported class");
    }
    if (SqlKeywords.isRegprocKeyword(type) || SqlKeywords.isRegprocedureKeyword(type)) {
        // return fake OID
        return new IntConstant(289208840);
    }
    if (SqlKeywords.isTimestampKeyword(type)) {
        return new ToTimestampFunctionFactory.ToTimestampFunction(nameFunction);
    }
    if (SqlKeywords.isDateKeyword(type)) {
        return new ToPgDateFunctionFactory.ToPgDateFunction(nameFunction);
    }
    if (SqlKeywords.isTextArrayKeyword(type)) {
        return new StringToStringArrayFunction(argPositions.getQuick(0), nameFunction.getStr(null));
    }
    throw SqlException.$(argPositions.getQuick(1), "unsupported type");
}
Also used : Function(io.questdb.cairo.sql.Function) IntConstant(io.questdb.griffin.engine.functions.constants.IntConstant)

Aggregations

Function (io.questdb.cairo.sql.Function)1 IntConstant (io.questdb.griffin.engine.functions.constants.IntConstant)1