use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class JoinNode method findTbNameByUsing.
private String findTbNameByUsing(PlanNode node, String using) {
String table = node.getCombinedName();
if (table != null) {
return table;
}
boolean found = false;
for (NamedField field : node.getOuterFields().keySet()) {
if (field.getName().equalsIgnoreCase(using)) {
if (!found) {
found = true;
table = field.getTable();
} else {
throw new MySQLOutPutException(ErrorCode.ER_NON_UNIQ_ERROR, "23000", " Column '" + using + "' in from clause is ambiguous");
}
}
}
return table;
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class PlanNode method setUpSelects.
protected void setUpSelects() {
if (columnsSelected.isEmpty()) {
columnsSelected.add(new ItemField(null, null, "*"));
}
boolean withWild = false;
for (Item sel : columnsSelected) {
if (sel.isWild())
withWild = true;
}
if (withWild)
dealStarColumn();
outerFields.clear();
nameContext.setFindInSelect(false);
nameContext.setSelectFirst(false);
for (Item sel : columnsSelected) {
setUpItem(sel);
NamedField field = makeOutNamedField(sel);
if (outerFields.containsKey(field) && getParent() != null)
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "duplicate field");
outerFields.put(field, sel);
}
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class PlanNode method dealStarColumn.
protected void dealStarColumn() {
List<Item> newSels = new ArrayList<>();
for (Item selItem : columnsSelected) {
if (selItem.isWild()) {
ItemField wildField = (ItemField) selItem;
if (wildField.getTableName() == null || wildField.getTableName().length() == 0) {
dealSingleStarColumn(newSels);
} else {
String selTable = wildField.getTableName();
boolean found = false;
for (NamedField field : innerFields.keySet()) {
if (selTable.equals(field.getTable())) {
ItemField col = new ItemField(null, field.getTable(), field.getName());
newSels.add(col);
found = true;
} else if (found) {
// a.* ->a.id,a.id1,b.id ,break when find b.id
break;
}
}
if (!found) {
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "child table " + selTable + " not exist!");
}
}
} else {
newSels.add(selItem);
}
}
columnsSelected = newSels;
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class PlanNode method setUpInnerFields.
protected void setUpInnerFields() {
innerFields.clear();
String tmpFieldTable;
String tmpFieldName;
for (PlanNode child : children) {
child.setUpFields();
for (NamedField coutField : child.outerFields.keySet()) {
tmpFieldTable = child.getAlias() == null ? coutField.getTable() : child.getAlias();
tmpFieldName = coutField.getName();
NamedField tmpField = new NamedField(tmpFieldTable, tmpFieldName, coutField.planNode);
if (innerFields.containsKey(tmpField) && getParent() != null)
throw new MySQLOutPutException(ErrorCode.ER_DUP_FIELDNAME, "42S21", "Duplicate column name '" + tmpFieldName + "'");
innerFields.put(tmpField, coutField);
}
}
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class MySQLPlanNodeVisitor method addJoinOnColumns.
private void addJoinOnColumns(Item ifilter, JoinNode joinNode) {
if (ifilter instanceof ItemFuncEqual) {
ItemFuncEqual filter = (ItemFuncEqual) ifilter;
Item column = filter.arguments().get(0);
Item value = filter.arguments().get(1);
if (column != null && column instanceof ItemField && value != null && value instanceof ItemField) {
joinNode.addJoinFilter(filter);
} else {
joinNode.setOtherJoinOnFilter(filter);
}
} else if (ifilter instanceof ItemCondAnd) {
ItemCondAnd ilfand = (ItemCondAnd) ifilter;
List<Item> subFilter = ilfand.arguments();
if (subFilter != null) {
for (Item arg : subFilter) {
Item orgOtherJoin = joinNode.getOtherJoinOnFilter();
addJoinOnColumns(arg, joinNode);
joinNode.setOtherJoinOnFilter(FilterUtils.and(orgOtherJoin, joinNode.getOtherJoinOnFilter()));
}
} else {
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "and has no other columns , " + ifilter);
}
} else {
joinNode.setOtherJoinOnFilter(ifilter);
}
}
Aggregations