use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.
the class QueryNodeHandlerBuilder method buildPre.
@Override
public List<DMLResponseHandler> buildPre() {
List<DMLResponseHandler> pres = new ArrayList<>();
PlanNode subNode = node.getChild();
BaseHandlerBuilder builder = hBuilder.getBuilder(session, subNode, isExplain);
if (builder.getSubQueryBuilderList().size() > 0) {
this.getSubQueryBuilderList().addAll(builder.getSubQueryBuilderList());
}
DMLResponseHandler subHandler = builder.getEndHandler();
pres.add(subHandler);
return pres;
}
use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.
the class ItemField method getMergeNodeColumn.
private Item getMergeNodeColumn(String tmpFieldTable, String tmpFieldName, PlanNode planNode) {
// select union only found in outerfields
Item column;
if (StringUtils.isEmpty(getTableName())) {
PlanNode firstNode = planNode.getChild();
boolean found = false;
for (NamedField coutField : firstNode.getOuterFields().keySet()) {
if (tmpFieldName.equalsIgnoreCase(coutField.getName())) {
if (!found) {
tmpFieldTable = coutField.getTable();
found = true;
} else {
throw new MySQLOutPutException(ErrorCode.ER_BAD_FIELD_ERROR, "(42S22", "Unknown column '" + tmpFieldName + "' in 'order clause'");
}
}
}
column = planNode.getOuterFields().get(new NamedField(tmpFieldTable, tmpFieldName, null));
} else {
throw new MySQLOutPutException(ErrorCode.ER_TABLENAME_NOT_ALLOWED_HERE, "42000", "Table '" + getTableName() + "' from one of the SELECTs cannot be used in global ORDER clause");
}
return column;
}
use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.
the class ItemField method fixFields.
@Override
public Item fixFields(NameResolutionContext context) {
if (this.isWild())
return this;
String tmpFieldTable = null;
String tmpFieldName = getItemName();
PlanNode planNode = context.getPlanNode();
if (context.getPlanNode().type() == PlanNodeType.MERGE) {
return getMergeNodeColumn(tmpFieldTable, tmpFieldName, planNode);
}
Item column = null;
if (context.isFindInSelect()) {
// try to find in selectlist
if (StringUtils.isEmpty(getTableName())) {
for (NamedField namedField : planNode.getOuterFields().keySet()) {
if (StringUtils.equalsIgnoreCase(tmpFieldName, namedField.getName())) {
if (column == null) {
column = planNode.getOuterFields().get(namedField);
} else
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "42S22", "duplicate column:" + this);
}
}
} else {
tmpFieldTable = getTableName();
column = planNode.getOuterFields().get(new NamedField(tmpFieldTable, tmpFieldName, null));
}
}
if (column != null && context.isSelectFirst()) {
return column;
}
// find from inner fields
Item columnFromMeta = null;
if (StringUtils.isEmpty(getTableName())) {
for (NamedField namedField : planNode.getInnerFields().keySet()) {
if (StringUtils.equalsIgnoreCase(tmpFieldName, namedField.getName())) {
if (columnFromMeta == null) {
tmpFieldTable = namedField.getTable();
NamedField coutField = planNode.getInnerFields().get(new NamedField(tmpFieldTable, tmpFieldName, null));
this.tableName = namedField.getTable();
getReferTables().clear();
this.getReferTables().add(coutField.planNode);
columnFromMeta = this;
} else {
if (planNode.type() == PlanNodeType.JOIN) {
JoinNode jn = (JoinNode) planNode;
if (jn.getUsingFields() != null && jn.getUsingFields().contains(columnFromMeta.getItemName().toLowerCase())) {
continue;
}
}
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "42S22", "duplicate column:" + this);
}
}
}
} else {
tmpFieldTable = getTableName();
NamedField tmpField = new NamedField(tmpFieldTable, tmpFieldName, null);
if (planNode.getInnerFields().containsKey(tmpField)) {
NamedField coutField = planNode.getInnerFields().get(tmpField);
getReferTables().clear();
getReferTables().add(coutField.planNode);
this.tableName = tmpField.getTable();
columnFromMeta = this;
}
}
if (columnFromMeta != null) {
return columnFromMeta;
} else if (column == null)
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "42S22", "column " + this + " not found");
else {
return column;
}
}
use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.
the class ItemField method fixRefer.
@Override
public void fixRefer(ReferContext context) {
if (isWild())
return;
PlanNode node = context.getPlanNode();
PlanNode tn = getReferTables().iterator().next();
node.addSelToReferedMap(tn, this);
}
use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.
the class FilterPusher method getQueryNode.
private static PlanNode getQueryNode(PlanNode qtn, List<Item> dnfNodeToPush) {
if (qtn.getSubQueries().size() > 0) {
Item node = FilterUtils.and(dnfNodeToPush);
if (node != null) {
qtn.query(FilterUtils.and(qtn.getWhereFilter(), node));
}
return qtn;
}
refreshPdFilters(qtn, dnfNodeToPush);
PlanNode child = pushFilter(qtn.getChild(), dnfNodeToPush);
((QueryNode) qtn).setChild(child);
return qtn;
}
Aggregations