Search in sources :

Example 1 with FunctionType

use of com.pingcap.tikv.expression.AggregateFunction.FunctionType in project tispark by pingcap.

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) FuncCallExpr(com.pingcap.tikv.expression.FuncCallExpr) Expression(com.pingcap.tikv.expression.Expression) ArithmeticBinaryExpression(com.pingcap.tikv.expression.ArithmeticBinaryExpression) StringRegExpression(com.pingcap.tikv.expression.StringRegExpression) ComparisonBinaryExpression(com.pingcap.tikv.expression.ComparisonBinaryExpression) LogicalBinaryExpression(com.pingcap.tikv.expression.LogicalBinaryExpression) FunctionType(com.pingcap.tikv.expression.AggregateFunction.FunctionType)

Aggregations

Expr (com.pingcap.tidb.tipb.Expr)1 FunctionType (com.pingcap.tikv.expression.AggregateFunction.FunctionType)1 ArithmeticBinaryExpression (com.pingcap.tikv.expression.ArithmeticBinaryExpression)1 ComparisonBinaryExpression (com.pingcap.tikv.expression.ComparisonBinaryExpression)1 Expression (com.pingcap.tikv.expression.Expression)1 FuncCallExpr (com.pingcap.tikv.expression.FuncCallExpr)1 LogicalBinaryExpression (com.pingcap.tikv.expression.LogicalBinaryExpression)1 StringRegExpression (com.pingcap.tikv.expression.StringRegExpression)1