use of com.actiontech.dble.plan.common.item.ItemField in project dble by actiontech.
the class FilterPusher method replaceFunctionArg.
/**
* replaceFunctionArg
*
* @param f
* @param sels1
* @param sels2
* @return if f also contains selectable which is not sels1 ,return null
*/
public static ItemFunc replaceFunctionArg(ItemFunc f, List<Item> sels1, List<Item> sels2) {
ItemFunc ret = (ItemFunc) f.cloneStruct();
for (int index = 0; index < ret.getArgCount(); index++) {
Item arg = ret.arguments().get(index);
if (arg instanceof ItemFunc) {
ItemFunc newfArg = replaceFunctionArg((ItemFunc) arg, sels1, sels2);
if (newfArg == null)
return null;
else
ret.arguments().set(index, newfArg);
} else if (arg instanceof ItemField) {
int tmpIndex = sels1.indexOf(arg);
if (tmpIndex < 0) {
return null;
} else {
Item newArg = sels2.get(tmpIndex);
ret.arguments().set(index, newArg.cloneStruct());
}
} else {
// do nothing;
}
}
ret.setPushDownName(null);
PlanUtil.refreshReferTables(ret);
return ret;
}
use of com.actiontech.dble.plan.common.item.ItemField in project dble by actiontech.
the class JoinNode method dealSingleStarColumn.
@Override
protected void dealSingleStarColumn(List<Item> newSels) {
if (usingFields == null) {
super.dealSingleStarColumn(newSels);
} else {
PlanNode driverNode = this.isRightOuterJoin() ? this.getRightNode() : this.getLeftNode();
String table = findTbNameByUsing(driverNode, usingFields.get(0));
for (String fieldName : usingFields) {
ItemField col = new ItemField(null, table, fieldName);
newSels.add(col);
}
for (NamedField field : innerFields.keySet()) {
if (usingFields.contains(field.getName())) {
continue;
}
ItemField col = new ItemField(null, field.getTable(), field.getName());
newSels.add(col);
}
}
}
use of com.actiontech.dble.plan.common.item.ItemField in project dble by actiontech.
the class JoinNode method genJoinFilter.
private ItemFuncEqual genJoinFilter(String using, String leftJoinNode, String rightJoinNode) {
ItemField column1 = new ItemField(null, leftJoinNode, using);
ItemField column2 = new ItemField(null, rightJoinNode, using);
return new ItemFuncEqual(column1, column2);
}
use of com.actiontech.dble.plan.common.item.ItemField 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.item.ItemField in project dble by actiontech.
the class ERJoinChooser method getLeftOutJoinChildER.
private ERTable getLeftOutJoinChildER(JoinNode joinNode, PlanNode child, Item onItem) {
if (PlanUtil.existAggregate(child))
return null;
else if (!PlanUtil.isERNode(child) && child.type() != PlanNode.PlanNodeType.TABLE)
return null;
if (onItem == null || !onItem.type().equals(Item.ItemType.FIELD_ITEM))
return null;
Pair<TableNode, ItemField> joinColumnInfo = PlanUtil.findColumnInTableLeaf((ItemField) onItem, joinNode);
if (joinColumnInfo == null)
return null;
TableNode tn = joinColumnInfo.getKey();
ItemField col = joinColumnInfo.getValue();
ERTable erKey = new ERTable(tn.getSchema(), tn.getPureName(), col.getItemName());
if (child.type() == PlanNode.PlanNodeType.TABLE) {
return erKey;
} else {
// joinnode
List<ERTable> erKeys = ((JoinNode) child).getERkeys();
for (ERTable cerKey : erKeys) {
if (isErRelation(erKey, cerKey))
return erKey;
}
return null;
}
}
Aggregations