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);
}
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);
}
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);
}
}
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);
}
}
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);
}
Aggregations