use of com.actiontech.dble.plan.NamedField 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.NamedField 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.NamedField 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.NamedField in project dble by actiontech.
the class TableNode method dealStarColumn.
@Override
protected void dealStarColumn() {
List<Item> newSelects = new ArrayList<>();
for (Item sel : columnsSelected) {
if (!sel.isWild())
newSelects.add(sel);
else {
for (NamedField innerField : innerFields.keySet()) {
ItemField col = new ItemField(null, sel.getTableName(), innerField.getName());
newSelects.add(col);
}
}
}
columnsSelected = newSelects;
}
use of com.actiontech.dble.plan.NamedField in project dble by actiontech.
the class PlanUtil method findColumnInTableLeaf.
/**
* check obj is the column of an real tablenode ,if obj is not Column Type return null
* <the column to be found must be table's parent's column>
*
* @param column column
* @param node node
* @return the target table node and the column
*/
public static Pair<TableNode, ItemField> findColumnInTableLeaf(ItemField column, PlanNode node) {
// union return
if (node.type() == PlanNodeType.MERGE)
return null;
NamedField tmpField = new NamedField(column.getTableName(), column.getItemName(), null);
NamedField coutField = node.getInnerFields().get(tmpField);
if (coutField == null)
return null;
else if (node.type() == PlanNodeType.TABLE) {
return new Pair<>((TableNode) node, column);
} else {
PlanNode referNode = column.getReferTables().iterator().next();
Item cSel = referNode.getOuterFields().get(coutField);
if (cSel instanceof ItemField) {
return findColumnInTableLeaf((ItemField) cSel, referNode);
} else {
return null;
}
}
}
Aggregations