Search in sources :

Example 1 with IndexedParameterLinkFunction

use of io.questdb.griffin.engine.functions.bind.IndexedParameterLinkFunction in project questdb by bluestreak01.

the class AbstractLikeStrFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) throws SqlException {
    final Function value = args.getQuick(0);
    final Function pattern = args.getQuick(1);
    if (pattern.isConstant()) {
        final CharSequence likeString = pattern.getStr(null);
        if (likeString != null && likeString.length() > 0) {
            String p = escapeSpecialChars(likeString, null);
            assert p != null;
            return new ConstLikeStrFunction(value, Pattern.compile(p, Pattern.DOTALL).matcher(""));
        }
        return BooleanConstant.FALSE;
    }
    if (pattern instanceof IndexedParameterLinkFunction) {
        // bind variable
        return new BindLikeStrFunction(value, pattern);
    }
    throw SqlException.$(argPositions.getQuick(1), "use constant or bind variable");
}
Also used : IndexedParameterLinkFunction(io.questdb.griffin.engine.functions.bind.IndexedParameterLinkFunction) UnaryFunction(io.questdb.griffin.engine.functions.UnaryFunction) Function(io.questdb.cairo.sql.Function) BooleanFunction(io.questdb.griffin.engine.functions.BooleanFunction) IndexedParameterLinkFunction(io.questdb.griffin.engine.functions.bind.IndexedParameterLinkFunction)

Aggregations

Function (io.questdb.cairo.sql.Function)1 BooleanFunction (io.questdb.griffin.engine.functions.BooleanFunction)1 UnaryFunction (io.questdb.griffin.engine.functions.UnaryFunction)1 IndexedParameterLinkFunction (io.questdb.griffin.engine.functions.bind.IndexedParameterLinkFunction)1