use of com.alibaba.cobar.parser.ast.fragment.tableref.TableReference in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(OuterJoin 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);
}
use of com.alibaba.cobar.parser.ast.fragment.tableref.TableReference in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(InnerJoin 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);
}
use of com.alibaba.cobar.parser.ast.fragment.tableref.TableReference in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(DMLUpdateStatement node) {
TableReference tr = node.getTableRefs();
visitChild(1, false, false, tr);
List<Pair<Identifier, Expression>> assignmentList = node.getValues();
if (assignmentList != null && !assignmentList.isEmpty()) {
List<ASTNode> list = new ArrayList<ASTNode>(assignmentList.size() * 2);
for (Pair<Identifier, Expression> p : assignmentList) {
if (p == null)
continue;
list.add(p.getKey());
list.add(p.getValue());
}
visitChild(2, false, false, list);
}
Expression where = node.getWhere();
visitChild(2, verdictColumn, false, where);
OrderBy order = node.getOrderBy();
visitChild(2, false, false, order);
}
use of com.alibaba.cobar.parser.ast.fragment.tableref.TableReference in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(InnerJoin node) {
TableReference left = node.getLeftTableRef();
boolean paren = left.getPrecedence() < node.getPrecedence();
if (paren)
appendable.append('(');
left.accept(this);
if (paren)
appendable.append(')');
appendable.append(" INNER JOIN ");
TableReference right = node.getRightTableRef();
paren = right.getPrecedence() <= node.getPrecedence();
if (paren)
appendable.append('(');
right.accept(this);
if (paren)
appendable.append(')');
Expression on = node.getOnCond();
List<String> using = node.getUsing();
if (on != null) {
appendable.append(" ON ");
on.accept(this);
} else if (using != null) {
appendable.append(" USING (");
boolean isFst = true;
for (String col : using) {
if (isFst)
isFst = false;
else
appendable.append(", ");
appendable.append(col);
}
appendable.append(")");
}
}
use of com.alibaba.cobar.parser.ast.fragment.tableref.TableReference in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(OuterJoin node) {
TableReference left = node.getLeftTableRef();
boolean paren = left.getPrecedence() < node.getPrecedence();
if (paren)
appendable.append('(');
left.accept(this);
if (paren)
appendable.append(')');
if (node.isLeftJoin())
appendable.append(" LEFT JOIN ");
else
appendable.append(" RIGHT JOIN ");
TableReference right = node.getRightTableRef();
paren = right.getPrecedence() <= node.getPrecedence();
if (paren)
appendable.append('(');
right.accept(this);
if (paren)
appendable.append(')');
Expression on = node.getOnCond();
List<String> using = node.getUsing();
if (on != null) {
appendable.append(" ON ");
on.accept(this);
} else if (using != null) {
appendable.append(" USING (");
boolean isFst = true;
for (String col : using) {
if (isFst)
isFst = false;
else
appendable.append(", ");
appendable.append(col);
}
appendable.append(")");
} else {
throw new IllegalArgumentException("either ON or USING must be included for OUTER JOIN");
}
}
Aggregations