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");
}
Aggregations