Search in sources :

Example 11 with NamedField

use of com.actiontech.dble.plan.NamedField in project dble by actiontech.

the class PlanUtil method pushDownCol.

// ----------------help method------------
private static Item pushDownCol(PlanNode node, ItemField col) {
    NamedField tmpField = new NamedField(col.getTableName(), col.getItemName(), null);
    NamedField coutField = node.getInnerFields().get(tmpField);
    return coutField.planNode.getOuterFields().get(coutField);
}
Also used : NamedField(com.actiontech.dble.plan.NamedField)

Example 12 with NamedField

use of com.actiontech.dble.plan.NamedField 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 NamedField

use of com.actiontech.dble.plan.NamedField 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 14 with NamedField

use of com.actiontech.dble.plan.NamedField in project dble by actiontech.

the class QueryNode method setUpInnerFields.

@Override
protected void setUpInnerFields() {
    innerFields.clear();
    for (PlanNode child : children) {
        child.setUpFields();
        for (NamedField childOutField : child.outerFields.keySet()) {
            NamedField tmpField = new NamedField(this.getAlias(), childOutField.getName(), childOutField.planNode);
            if (innerFields.containsKey(tmpField) && getParent() != null)
                throw new MySQLOutPutException(ErrorCode.ER_DUP_FIELDNAME, "42S21", "Duplicate column name '" + childOutField.getName() + "'");
            innerFields.put(tmpField, childOutField);
        }
    }
}
Also used : NamedField(com.actiontech.dble.plan.NamedField) MySQLOutPutException(com.actiontech.dble.plan.common.exception.MySQLOutPutException)

Example 15 with NamedField

use of com.actiontech.dble.plan.NamedField in project dble by actiontech.

the class TableNode method setUpInnerFields.

@Override
protected void setUpInnerFields() {
    innerFields.clear();
    String tmpTable = alias == null ? tableName : alias;
    for (StructureMeta.ColumnMeta cm : tableMeta.getColumnsList()) {
        NamedField tmpField = new NamedField(tmpTable, cm.getName(), this);
        innerFields.put(tmpField, tmpField);
    }
}
Also used : NamedField(com.actiontech.dble.plan.NamedField) StructureMeta(com.actiontech.dble.meta.protocol.StructureMeta)

Aggregations

NamedField (com.actiontech.dble.plan.NamedField)15 MySQLOutPutException (com.actiontech.dble.plan.common.exception.MySQLOutPutException)9 ItemField (com.actiontech.dble.plan.common.item.ItemField)6 Item (com.actiontech.dble.plan.common.item.Item)3 PlanNode (com.actiontech.dble.plan.node.PlanNode)3 StructureMeta (com.actiontech.dble.meta.protocol.StructureMeta)1 JoinNode (com.actiontech.dble.plan.node.JoinNode)1 TableNode (com.actiontech.dble.plan.node.TableNode)1 ArrayList (java.util.ArrayList)1