Search in sources :

Example 11 with ItemField

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;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) ItemFunc(com.actiontech.dble.plan.common.item.function.ItemFunc) ItemField(com.actiontech.dble.plan.common.item.ItemField)

Example 12 with ItemField

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);
        }
    }
}
Also used : NamedField(com.actiontech.dble.plan.NamedField) ItemField(com.actiontech.dble.plan.common.item.ItemField)

Example 13 with ItemField

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);
}
Also used : ItemFuncEqual(com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual) ItemField(com.actiontech.dble.plan.common.item.ItemField)

Example 14 with ItemField

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);
    }
}
Also used : NamedField(com.actiontech.dble.plan.NamedField) ItemField(com.actiontech.dble.plan.common.item.ItemField) MySQLOutPutException(com.actiontech.dble.plan.common.exception.MySQLOutPutException)

Example 15 with ItemField

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;
    }
}
Also used : JoinNode(com.actiontech.dble.plan.node.JoinNode) TableNode(com.actiontech.dble.plan.node.TableNode) ERTable(com.actiontech.dble.config.model.ERTable) ItemField(com.actiontech.dble.plan.common.item.ItemField)

Aggregations

ItemField (com.actiontech.dble.plan.common.item.ItemField)20 Item (com.actiontech.dble.plan.common.item.Item)10 NamedField (com.actiontech.dble.plan.NamedField)6 MySQLOutPutException (com.actiontech.dble.plan.common.exception.MySQLOutPutException)6 ItemFuncEqual (com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual)4 ArrayList (java.util.ArrayList)4 ItemFunc (com.actiontech.dble.plan.common.item.function.ItemFunc)3 JoinNode (com.actiontech.dble.plan.node.JoinNode)3 TableNode (com.actiontech.dble.plan.node.TableNode)3 ERTable (com.actiontech.dble.config.model.ERTable)2 Order (com.actiontech.dble.plan.Order)2 Field (com.actiontech.dble.plan.common.field.Field)2 RowDataComparator (com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)1 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)1 ItemCondAnd (com.actiontech.dble.plan.common.item.function.operator.logic.ItemCondAnd)1 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)1 PlanNode (com.actiontech.dble.plan.node.PlanNode)1 QueryNode (com.actiontech.dble.plan.node.QueryNode)1 List (java.util.List)1