use of com.actiontech.dble.plan.common.item.ItemField 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.ItemField 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.common.item.ItemField in project dble by actiontech.
the class ERJoinChooser method nodeHasSelectable.
private Item nodeHasSelectable(PlanNode child, Item sel) {
if (sel instanceof ItemField) {
return nodeHasColumn(child, (ItemField) sel);
} else if (sel.canValued()) {
return sel;
} else if (sel.type().equals(Item.ItemType.SUM_FUNC_ITEM)) {
return null;
} else {
ItemFunc fcopy = (ItemFunc) sel.cloneStruct();
for (int index = 0; index < fcopy.getArgCount(); index++) {
Item arg = fcopy.arguments().get(index);
Item argSel = nodeHasSelectable(child, arg);
if (argSel == null)
return null;
else
fcopy.arguments().set(index, argSel);
}
PlanUtil.refreshReferTables(fcopy);
fcopy.setPushDownName(null);
return fcopy;
}
}
use of com.actiontech.dble.plan.common.item.ItemField in project dble by actiontech.
the class FilterJoinColumnPusher method isPossibleERJoinColumnFilter.
/**
* is ER Filter: 1.Filter must be equal(=) 2.Filter must be Column = Column
* 3.Filter's key and value must be belong different table ex:a.id=b.id true a.id=b.id+1 false
*/
private static boolean isPossibleERJoinColumnFilter(PlanNode node, Item ifilter) {
if (!(ifilter instanceof ItemFuncEqual))
return false;
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) {
Pair<TableNode, ItemField> foundColumn = PlanUtil.findColumnInTableLeaf((ItemField) column, node);
Pair<TableNode, ItemField> foundValue = PlanUtil.findColumnInTableLeaf((ItemField) value, node);
if (foundColumn != null && foundValue != null) {
String columnTable = foundColumn.getValue().getTableName();
String valueTable = foundValue.getValue().getTableName();
// the table must be different
return !StringUtils.equals(columnTable, valueTable);
} else {
return false;
}
} else {
return false;
}
}
use of com.actiontech.dble.plan.common.item.ItemField 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