use of com.pingcap.tidb.tipb.Expr in project client-java by tikv.
the class ProtoConverter method visit.
@Override
protected Expr visit(StringRegExpression node, Object context) {
// assume after type coerce, children should be compatible
ScalarFuncSig protoSig;
switch(node.getRegType()) {
case STARTS_WITH:
case CONTAINS:
case ENDS_WITH:
case LIKE:
protoSig = ScalarFuncSig.LikeSig;
break;
default:
throw new TiExpressionException(String.format("Unknown reg type %s", node.getRegType()));
}
Expr.Builder builder = scalarToPartialProto(node, context);
builder.setSig(protoSig);
return builder.build();
}
use of com.pingcap.tidb.tipb.Expr in project client-java by tikv.
the class ProtoConverter method visit.
@Override
protected Expr visit(Not node, Object context) {
ScalarFuncSig protoSig = null;
DataType dataType = getType(node);
switch(dataType.getType()) {
case TypeDecimal:
protoSig = ScalarFuncSig.UnaryNotDecimal;
break;
case TypeDouble:
case TypeFloat:
protoSig = ScalarFuncSig.UnaryNotReal;
break;
case TypeInt24:
case TypeLong:
case TypeShort:
case TypeLonglong:
case TypeTiny:
protoSig = ScalarFuncSig.UnaryNotInt;
break;
default:
}
Objects.requireNonNull(protoSig, "unary not can not find proper proto signature.");
Expr.Builder builder = scalarToPartialProto(node, context);
builder.setSig(protoSig);
builder.setFieldType(toPBFieldType(getType(node)));
return builder.build();
}
use of com.pingcap.tidb.tipb.Expr in project client-java by tikv.
the class ProtoConverter method visit.
@Override
protected Expr visit(AggregateFunction node, Object context) {
Expr.Builder builder = Expr.newBuilder();
FunctionType type = node.getType();
switch(type) {
case Max:
builder.setTp(ExprType.Max);
break;
case Sum:
builder.setTp(ExprType.Sum);
break;
case Min:
builder.setTp(ExprType.Min);
break;
case First:
builder.setTp(ExprType.First);
break;
case Count:
builder.setTp(ExprType.Count);
break;
}
for (Expression arg : node.getChildren()) {
Expr exprProto = arg.accept(this, context);
builder.addChildren(exprProto);
}
builder.setFieldType(toPBFieldType(getType(node)));
return builder.build();
}
Aggregations