use of com.alibaba.cobar.parser.ast.expression.misc.QueryExpression in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(SubqueryFactor node) {
QueryExpression query = node.getSubquery();
visitChild(2, verdictColumn, verdictGroupFunc, query);
}
use of com.alibaba.cobar.parser.ast.expression.misc.QueryExpression in project cobar by alibaba.
the class PartitionKeyVisitor method insertReplace.
private void insertReplace(DMLInsertReplaceStatement node) {
Identifier table = node.getTable();
List<Identifier> collist = node.getColumnNameList();
QueryExpression query = node.getSelect();
List<RowExpression> rows = node.getRowList();
tableAsTableFactor(table);
String tableName = table.getIdTextUpUnescape();
visitChild(2, false, false, collist);
if (query != null) {
query.accept(this);
return;
}
for (RowExpression row : rows) {
visitChild(2, false, false, row);
}
Map<String, List<Object>> colVals = ensureColumnValueByTable(tableName);
Map<String, Map<Object, Set<Pair<Expression, ASTNode>>>> colValsIndex = ensureColumnValueIndexByTable(tableName);
if (collist != null) {
for (int i = 0; i < collist.size(); ++i) {
String colName = collist.get(i).getIdTextUpUnescape();
if (isRuledColumn(tableName, colName)) {
List<Object> valueList = ensureColumnValueList(colVals, colName);
Map<Object, Set<Pair<Expression, ASTNode>>> valMap = ensureColumnValueIndexObjMap(colValsIndex, colName);
for (RowExpression row : rows) {
Expression expr = row.getRowExprList().get(i);
Object value = expr == null ? null : expr.evaluation(evaluationParameter);
if (value != Expression.UNEVALUATABLE) {
valueList.add(value);
addIntoColumnValueIndex(valMap, value, row, node);
}
}
}
}
}
}
use of com.alibaba.cobar.parser.ast.expression.misc.QueryExpression in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(SubqueryFactor node) {
appendable.append('(');
QueryExpression query = node.getSubquery();
query.accept(this);
appendable.append(") AS ").append(node.getAlias());
}
Aggregations