Search in sources :

Example 96 with Expression

use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.

the class PartitionKeyVisitor method sortPairList.

private void sortPairList(List<Pair<Expression, SortOrder>> list) {
    if (list == null || list.isEmpty())
        return;
    Expression[] exprs = new Expression[list.size()];
    int i = 0;
    for (Pair<Expression, SortOrder> p : list) {
        exprs[i] = p.getKey();
        ++i;
    }
    visitChild(2, false, false, exprs);
}
Also used : BetweenAndExpression(com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression) ComparisionEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression) QueryExpression(com.alibaba.cobar.parser.ast.expression.misc.QueryExpression) InExpression(com.alibaba.cobar.parser.ast.expression.comparison.InExpression) FunctionExpression(com.alibaba.cobar.parser.ast.expression.primary.function.FunctionExpression) MatchExpression(com.alibaba.cobar.parser.ast.expression.primary.MatchExpression) ComparisionIsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression) LogicalOrExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression) ReplacableExpression(com.alibaba.cobar.parser.ast.expression.ReplacableExpression) LogicalAndExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression) UnaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression) ComparisionNullSafeEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression) LikeExpression(com.alibaba.cobar.parser.ast.expression.string.LikeExpression) CollateExpression(com.alibaba.cobar.parser.ast.expression.type.CollateExpression) Expression(com.alibaba.cobar.parser.ast.expression.Expression) CaseWhenOperatorExpression(com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression) UserExpression(com.alibaba.cobar.parser.ast.expression.misc.UserExpression) PolyadicOperatorExpression(com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression) BinaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression) RowExpression(com.alibaba.cobar.parser.ast.expression.primary.RowExpression) SortOrder(com.alibaba.cobar.parser.ast.fragment.SortOrder) IndexHint(com.alibaba.cobar.parser.ast.fragment.tableref.IndexHint)

Example 97 with Expression

use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.

the class PartitionKeyVisitor method visit.

@Override
public void visit(DMLSelectStatement node) {
    boolean verdictGroup = true;
    List<Expression> exprList = node.getSelectExprListWithoutAlias();
    if (verdictGroupFunc) {
        for (Expression expr : exprList) {
            if (!isGroupFuncPassthroughSelect(expr)) {
                groupFuncType = GROUP_CANCEL;
                verdictGroup = false;
                break;
            }
        }
        limit(node.getLimit());
    }
    visitChild(2, false, verdictGroupFunc && verdictGroup, exprList);
    TableReference tr = node.getTables();
    visitChild(1, verdictColumn, verdictGroupFunc && verdictGroup, tr);
    Expression where = node.getWhere();
    visitChild(2, verdictColumn, false, where);
    GroupBy group = node.getGroup();
    visitChild(2, false, false, group);
    Expression having = node.getHaving();
    visitChild(2, verdictColumn, false, having);
    OrderBy order = node.getOrder();
    visitChild(2, false, false, order);
}
Also used : OrderBy(com.alibaba.cobar.parser.ast.fragment.OrderBy) TableReference(com.alibaba.cobar.parser.ast.fragment.tableref.TableReference) GroupBy(com.alibaba.cobar.parser.ast.fragment.GroupBy) BetweenAndExpression(com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression) ComparisionEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression) QueryExpression(com.alibaba.cobar.parser.ast.expression.misc.QueryExpression) InExpression(com.alibaba.cobar.parser.ast.expression.comparison.InExpression) FunctionExpression(com.alibaba.cobar.parser.ast.expression.primary.function.FunctionExpression) MatchExpression(com.alibaba.cobar.parser.ast.expression.primary.MatchExpression) ComparisionIsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression) LogicalOrExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression) ReplacableExpression(com.alibaba.cobar.parser.ast.expression.ReplacableExpression) LogicalAndExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression) UnaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression) ComparisionNullSafeEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression) LikeExpression(com.alibaba.cobar.parser.ast.expression.string.LikeExpression) CollateExpression(com.alibaba.cobar.parser.ast.expression.type.CollateExpression) Expression(com.alibaba.cobar.parser.ast.expression.Expression) CaseWhenOperatorExpression(com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression) UserExpression(com.alibaba.cobar.parser.ast.expression.misc.UserExpression) PolyadicOperatorExpression(com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression) BinaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression) RowExpression(com.alibaba.cobar.parser.ast.expression.primary.RowExpression)

Example 98 with Expression

use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.

the class PartitionKeyVisitor method visit.

@Override
public void visit(DMLInsertStatement node) {
    insertReplace(node);
    List<Pair<Identifier, Expression>> dup = node.getDuplicateUpdate();
    if (dup != null) {
        ASTNode[] duplist = new ASTNode[dup.size() * 2];
        int i = 0;
        for (Pair<Identifier, Expression> p : dup) {
            Identifier key = null;
            Expression value = null;
            if (p != null) {
                key = p.getKey();
                value = p.getValue();
            }
            duplist[i++] = key;
            duplist[i++] = value;
        }
        visitChild(2, false, false, duplist);
    }
}
Also used : Identifier(com.alibaba.cobar.parser.ast.expression.primary.Identifier) BetweenAndExpression(com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression) ComparisionEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression) QueryExpression(com.alibaba.cobar.parser.ast.expression.misc.QueryExpression) InExpression(com.alibaba.cobar.parser.ast.expression.comparison.InExpression) FunctionExpression(com.alibaba.cobar.parser.ast.expression.primary.function.FunctionExpression) MatchExpression(com.alibaba.cobar.parser.ast.expression.primary.MatchExpression) ComparisionIsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression) LogicalOrExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression) ReplacableExpression(com.alibaba.cobar.parser.ast.expression.ReplacableExpression) LogicalAndExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression) UnaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression) ComparisionNullSafeEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression) LikeExpression(com.alibaba.cobar.parser.ast.expression.string.LikeExpression) CollateExpression(com.alibaba.cobar.parser.ast.expression.type.CollateExpression) Expression(com.alibaba.cobar.parser.ast.expression.Expression) CaseWhenOperatorExpression(com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression) UserExpression(com.alibaba.cobar.parser.ast.expression.misc.UserExpression) PolyadicOperatorExpression(com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression) BinaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression) RowExpression(com.alibaba.cobar.parser.ast.expression.primary.RowExpression) ASTNode(com.alibaba.cobar.parser.ast.ASTNode) IndexHint(com.alibaba.cobar.parser.ast.fragment.tableref.IndexHint) Pair(com.alibaba.cobar.parser.util.Pair)

Example 99 with Expression

use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.

the class PartitionKeyVisitor method visit.

@Override
public void visit(LogicalAndExpression node) {
    for (int i = 0, len = node.getArity(); i < len; ++i) {
        Expression oprand = node.getOperand(i);
        visitChild(2, verdictColumn && isVerdictPassthroughWhere(oprand), false, oprand);
    }
}
Also used : BetweenAndExpression(com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression) ComparisionEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression) QueryExpression(com.alibaba.cobar.parser.ast.expression.misc.QueryExpression) InExpression(com.alibaba.cobar.parser.ast.expression.comparison.InExpression) FunctionExpression(com.alibaba.cobar.parser.ast.expression.primary.function.FunctionExpression) MatchExpression(com.alibaba.cobar.parser.ast.expression.primary.MatchExpression) ComparisionIsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression) LogicalOrExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression) ReplacableExpression(com.alibaba.cobar.parser.ast.expression.ReplacableExpression) LogicalAndExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression) UnaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression) ComparisionNullSafeEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression) LikeExpression(com.alibaba.cobar.parser.ast.expression.string.LikeExpression) CollateExpression(com.alibaba.cobar.parser.ast.expression.type.CollateExpression) Expression(com.alibaba.cobar.parser.ast.expression.Expression) CaseWhenOperatorExpression(com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression) UserExpression(com.alibaba.cobar.parser.ast.expression.misc.UserExpression) PolyadicOperatorExpression(com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression) BinaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression) RowExpression(com.alibaba.cobar.parser.ast.expression.primary.RowExpression) IndexHint(com.alibaba.cobar.parser.ast.fragment.tableref.IndexHint)

Example 100 with Expression

use of com.alibaba.cobar.parser.ast.expression.Expression in project cobar by alibaba.

the class PartitionKeyVisitor method visit.

@Override
public void visit(StraightJoin node) {
    TableReference tr1 = node.getLeftTableRef();
    TableReference tr2 = node.getRightTableRef();
    Expression on = node.getOnCond();
    visitChild(1, verdictColumn, verdictGroupFunc, tr1, tr2);
    visitChild(2, verdictColumn && isVerdictPassthroughWhere(on), false, on);
}
Also used : TableReference(com.alibaba.cobar.parser.ast.fragment.tableref.TableReference) BetweenAndExpression(com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression) ComparisionEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression) QueryExpression(com.alibaba.cobar.parser.ast.expression.misc.QueryExpression) InExpression(com.alibaba.cobar.parser.ast.expression.comparison.InExpression) FunctionExpression(com.alibaba.cobar.parser.ast.expression.primary.function.FunctionExpression) MatchExpression(com.alibaba.cobar.parser.ast.expression.primary.MatchExpression) ComparisionIsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression) LogicalOrExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression) ReplacableExpression(com.alibaba.cobar.parser.ast.expression.ReplacableExpression) LogicalAndExpression(com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression) UnaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression) ComparisionNullSafeEqualsExpression(com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression) LikeExpression(com.alibaba.cobar.parser.ast.expression.string.LikeExpression) CollateExpression(com.alibaba.cobar.parser.ast.expression.type.CollateExpression) Expression(com.alibaba.cobar.parser.ast.expression.Expression) CaseWhenOperatorExpression(com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression) UserExpression(com.alibaba.cobar.parser.ast.expression.misc.UserExpression) PolyadicOperatorExpression(com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression) BinaryOperatorExpression(com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression) RowExpression(com.alibaba.cobar.parser.ast.expression.primary.RowExpression)

Aggregations

Expression (com.alibaba.cobar.parser.ast.expression.Expression)128 RowExpression (com.alibaba.cobar.parser.ast.expression.primary.RowExpression)96 QueryExpression (com.alibaba.cobar.parser.ast.expression.misc.QueryExpression)93 InExpression (com.alibaba.cobar.parser.ast.expression.comparison.InExpression)91 ComparisionEqualsExpression (com.alibaba.cobar.parser.ast.expression.comparison.ComparisionEqualsExpression)88 LogicalAndExpression (com.alibaba.cobar.parser.ast.expression.logical.LogicalAndExpression)88 BetweenAndExpression (com.alibaba.cobar.parser.ast.expression.comparison.BetweenAndExpression)87 ComparisionIsExpression (com.alibaba.cobar.parser.ast.expression.comparison.ComparisionIsExpression)87 ComparisionNullSafeEqualsExpression (com.alibaba.cobar.parser.ast.expression.comparison.ComparisionNullSafeEqualsExpression)87 LogicalOrExpression (com.alibaba.cobar.parser.ast.expression.logical.LogicalOrExpression)87 UserExpression (com.alibaba.cobar.parser.ast.expression.misc.UserExpression)87 CaseWhenOperatorExpression (com.alibaba.cobar.parser.ast.expression.primary.CaseWhenOperatorExpression)87 LikeExpression (com.alibaba.cobar.parser.ast.expression.string.LikeExpression)87 CollateExpression (com.alibaba.cobar.parser.ast.expression.type.CollateExpression)87 FunctionExpression (com.alibaba.cobar.parser.ast.expression.primary.function.FunctionExpression)76 MatchExpression (com.alibaba.cobar.parser.ast.expression.primary.MatchExpression)71 BinaryOperatorExpression (com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression)58 PolyadicOperatorExpression (com.alibaba.cobar.parser.ast.expression.PolyadicOperatorExpression)58 UnaryOperatorExpression (com.alibaba.cobar.parser.ast.expression.UnaryOperatorExpression)58 ArithmeticAddExpression (com.alibaba.cobar.parser.ast.expression.arithmeic.ArithmeticAddExpression)45