use of org.apache.calcite.sql.fun.SqlLikeOperator in project hazelcast by hazelcast.
the class HazelcastLikeOperator method reduceExpr.
@Override
public ReduceResult reduceExpr(int opOrdinal, TokenSequence list) {
SqlNode exp0 = list.node(opOrdinal - 1);
SqlOperator op = list.op(opOrdinal);
assert op instanceof SqlLikeOperator;
SqlNode exp1 = SqlParserUtil.toTreeEx(list, opOrdinal + 1, getRightPrec(), SqlKind.ESCAPE);
SqlNode exp2 = null;
if ((opOrdinal + 2) < list.size()) {
if (list.isOp(opOrdinal + 2)) {
SqlOperator op2 = list.op(opOrdinal + 2);
if (op2.getKind() == SqlKind.ESCAPE) {
exp2 = SqlParserUtil.toTreeEx(list, opOrdinal + 3, getRightPrec(), SqlKind.ESCAPE);
}
}
}
SqlNode[] operands;
int end;
if (exp2 != null) {
operands = new SqlNode[] { exp0, exp1, exp2 };
end = opOrdinal + 4;
} else {
operands = new SqlNode[] { exp0, exp1 };
end = opOrdinal + 2;
}
SqlCall call = createCall(SqlParserPos.ZERO, operands);
return new ReduceResult(opOrdinal - 1, end, call);
}
Aggregations