use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class MySQLPlanNodeVisitor method handleWhereCondition.
private void handleWhereCondition(SQLExpr whereExpr) {
MySQLItemVisitor mev = new MySQLItemVisitor(this.currentDb, this.charsetIndex, this.metaManager);
whereExpr.accept(mev);
if (this.tableNode != null) {
Item whereFilter = mev.getItem();
tableNode.query(whereFilter);
if (whereFilter.isWithSubQuery()) {
tableNode.setSubQuery(true);
tableNode.setCorrelatedSubQuery(whereFilter.isCorrelatedSubQuery());
}
} else {
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "from expression is null,check the sql!");
}
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class MySQLPlanNodeVisitor method handleSelectItems.
private List<Item> handleSelectItems(List<SQLSelectItem> items) {
List<Item> selectItems = new ArrayList<>();
for (SQLSelectItem item : items) {
SQLExpr expr = item.getExpr();
MySQLItemVisitor ev = new MySQLItemVisitor(currentDb, this.charsetIndex, this.metaManager);
expr.accept(ev);
Item selItem = ev.getItem();
if (selItem.isWithSubQuery()) {
setSubQueryNode(selItem);
}
selItem.setAlias(item.getAlias());
if (isSubQuery && selItem.getAlias() == null) {
selItem.setAlias("autoalias_scalar");
}
selectItems.add(selItem);
}
return selectItems;
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class FilterPusher method refreshPdFilters.
private static void refreshPdFilters(PlanNode qtn, List<Item> filters) {
for (int index = 0; index < filters.size(); index++) {
Item toPsFilter = filters.get(index);
Item pdFilter = PlanUtil.pushDownItem(qtn, toPsFilter);
filters.set(index, pdFilter);
}
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class FilterPusher method mergeJoinOnFilter.
/**
* merge inner joi's otheron to where if we can
*
* @param qtn
* @return
*/
private static void mergeJoinOnFilter(PlanNode qtn) {
if (PlanUtil.isGlobalOrER(qtn))
return;
if (qtn.type().equals(PlanNodeType.JOIN) && ((JoinNode) qtn).isInnerJoin()) {
JoinNode jn = (JoinNode) qtn;
Item otherJoinOn = jn.getOtherJoinOnFilter();
jn.setOtherJoinOnFilter(null);
jn.query(FilterUtils.and(otherJoinOn, jn.getWhereFilter()));
}
for (PlanNode child : qtn.getChildren()) {
mergeJoinOnFilter(child);
}
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class FilterPusher method getMergeNode.
private static PlanNode getMergeNode(PlanNode qtn, List<Item> dnfNodeToPush) {
// union's where can be pushed down ,but it must be replace to child's condition
Item node = FilterUtils.and(dnfNodeToPush);
if (node != null) {
qtn.query(FilterUtils.and(qtn.getWhereFilter(), node));
}
Item mergeWhere = qtn.getWhereFilter();
// push down merge's condition
qtn.query(null);
List<Item> pushFilters = PlanUtil.getPushItemsToUnionChild((MergeNode) qtn, mergeWhere, ((MergeNode) qtn).getColIndexs());
List<PlanNode> childs = qtn.getChildren();
for (int index = 0; index < childs.size(); index++) {
PlanNode child = childs.get(index);
if (pushFilters != null) {
Item pushFilter = pushFilters.get(index);
child.query(FilterUtils.and(child.getWhereFilter(), pushFilter));
}
FilterPusher.optimize(child);
}
return qtn;
}
Aggregations