use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class MySQLPlanNodeVisitor method visit.
public boolean visit(SQLExprTableSource tableSource) {
PlanNode table;
SQLExpr expr = tableSource.getExpr();
if (expr instanceof SQLPropertyExpr) {
SQLPropertyExpr propertyExpr = (SQLPropertyExpr) expr;
table = new TableNode(StringUtil.removeBackQuote(propertyExpr.getOwner().toString()), StringUtil.removeBackQuote(propertyExpr.getName()), this.metaManager);
containSchema = true;
} else if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identifierExpr = (SQLIdentifierExpr) expr;
if (identifierExpr.getName().equalsIgnoreCase("dual")) {
this.tableNode = new NoNameNode(currentDb, null);
return true;
}
// here to check if the table name is a view in metaManager
QueryNode viewNode = metaManager.getSyncView(currentDb, identifierExpr.getName());
if (viewNode != null) {
// consider if the table with other name
viewNode.setAlias(tableSource.getAlias() == null ? identifierExpr.getName() : tableSource.getAlias());
this.tableNode = viewNode;
this.tableNode.setSubQuery(true);
this.tableNode.setExistView(true);
return true;
} else {
table = new TableNode(this.currentDb, StringUtil.removeBackQuote(identifierExpr.getName()), this.metaManager);
}
} else {
throw new MySQLOutPutException(ErrorCode.ER_PARSE_ERROR, "42000", "table is " + tableSource.toString());
}
((TableNode) table).setHintList(tableSource.getHints());
this.tableNode = table;
return true;
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class MergeNode method setUpSelects.
@Override
protected void setUpSelects() {
columnsSelected.clear();
PlanNode firstNode = getChild();
outerFields.clear();
Set<NamedField> checkDup = new HashSet<>(firstNode.getOuterFields().size(), 1);
for (NamedField coutField : firstNode.getOuterFields().keySet()) {
ItemField column = new ItemField(null, null, coutField.getName());
NamedField tmpField = new NamedField(coutField.getTable(), coutField.getName(), this);
NamedField testDupField = new NamedField(null, coutField.getName(), this);
if (checkDup.contains(testDupField) && getParent() != null) {
throw new MySQLOutPutException(ErrorCode.ER_DUP_FIELDNAME, "", "Duplicate column name " + coutField.getName());
}
checkDup.add(testDupField);
outerFields.put(tmpField, column);
getColumnsSelected().add(column);
}
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class PlanNode method setUpGroupBy.
private void setUpGroupBy() {
nameContext.setFindInSelect(true);
nameContext.setSelectFirst(false);
for (Order order : groups) {
Item item = order.getItem();
if (item.type() == Item.ItemType.INT_ITEM) {
int index = item.valInt().intValue();
if (index >= 1 && index <= getColumnsSelected().size())
order.setItem(getColumnsSelected().get(index - 1));
else
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "Unknown column '" + index + "' in group statement");
} else {
order.setItem(setUpItem(item));
}
}
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class PlanNode method setUpOrderBy.
private void setUpOrderBy() {
nameContext.setFindInSelect(true);
nameContext.setSelectFirst(true);
for (Order order : orderBys) {
Item item = order.getItem();
if (item.type() == Item.ItemType.INT_ITEM) {
int index = item.valInt().intValue();
if (index >= 1 && index <= getColumnsSelected().size())
order.setItem(getColumnsSelected().get(index - 1));
else
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "Unknown column '" + index + "' in order statement");
} else {
order.setItem(setUpItem(item));
}
}
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class QueryNode method setUpInnerFields.
@Override
protected void setUpInnerFields() {
innerFields.clear();
for (PlanNode child : children) {
child.setUpFields();
for (NamedField childOutField : child.outerFields.keySet()) {
NamedField tmpField = new NamedField(this.getAlias(), childOutField.getName(), childOutField.planNode);
if (innerFields.containsKey(tmpField) && getParent() != null)
throw new MySQLOutPutException(ErrorCode.ER_DUP_FIELDNAME, "42S21", "Duplicate column name '" + childOutField.getName() + "'");
innerFields.put(tmpField, childOutField);
}
}
}
Aggregations