Search in sources :

Example 1 with FunctionType

use of org.tikv.common.expression.AggregateFunction.FunctionType 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();
}
Also used : Expr(com.pingcap.tidb.tipb.Expr) FunctionType(org.tikv.common.expression.AggregateFunction.FunctionType)

Aggregations

Expr (com.pingcap.tidb.tipb.Expr)1 FunctionType (org.tikv.common.expression.AggregateFunction.FunctionType)1