use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class JoinNode method buildJoinFilters.
private void buildJoinFilters() {
nameContext.setFindInSelect(false);
nameContext.setSelectFirst(false);
if (usingFields != null) {
for (String using : usingFields) {
using = StringUtil.removeBackQuote(using);
String lName = findTbNameByUsing(this.getLeftNode(), using);
String rName = findTbNameByUsing(this.getRightNode(), using);
if (lName.equals(rName)) {
throw new MySQLOutPutException(ErrorCode.ER_NONUNIQ_TABLE, "42000", "Not unique table/alias: '" + lName + "'");
}
Item filter = setUpItem(genJoinFilter(using, lName, rName));
joinFilter.add((ItemFuncEqual) filter);
}
} else {
for (int index = 0; index < joinFilter.size(); index++) {
Item bf = joinFilter.get(index);
bf = setUpItem(bf);
if (bf.getReferTables().size() == 1) {
throw new MySQLOutPutException(ErrorCode.ER_NONUNIQ_TABLE, "42000", "Not unique table/alias: '" + this.getLeftNode().getPureName() + "'");
}
joinFilter.set(index, (ItemFuncEqual) bf);
}
}
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class PlanNode method setUpRefers.
// column refered start
public void setUpRefers(boolean isPushDownNode) {
sumFuncs.clear();
referContext.setPushDownNode(isPushDownNode);
// select
for (Item sel : columnsSelected) {
setUpItemRefer(sel);
}
if (type() == PlanNodeType.JOIN) {
JoinNode jn = (JoinNode) this;
if (!isPushDownNode) {
for (Item bf : jn.getJoinFilter()) setUpItemRefer(bf);
setUpItemRefer(jn.getOtherJoinOnFilter());
}
}
// where, pushdown node does 't need where
if (!isPushDownNode) {
setUpItemRefer(whereFilter);
}
// group by
for (Order groupBy : groups) {
setUpItemRefer(groupBy.getItem());
}
// having
setUpItemRefer(havingFilter);
// order by
for (Order orderBy : orderBys) {
setUpItemRefer(orderBy.getItem());
}
// make list
for (List<Item> selSet : columnsReferredCache.asMap().values()) {
columnsReferList.addAll(selSet);
}
}
use of com.actiontech.dble.plan.common.item.Item 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.item.Item 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.item.Item 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;
}
Aggregations