private void errorFilterPushDown(LogicalPlan plan, LogicalNode node, FilterPushDownContext context) { String prefix = ""; StringBuilder notMatchedNodeStrBuilder = new StringBuilder(); for (EvalNode notMatchedNode: context.pushingDownFilters) { notMatchedNodeStrBuilder.append(prefix).append(notMatchedNode.toString()); if (prefix.isEmpty()) { prefix = ", "; } } throw new TajoInternalError("FilterPushDown failed cause some filters not matched: " + notMatchedNodeStrBuilder.toString() + "\n" + "Error node: " + node.getPlanString() + "\n" + plan.toString()); } }
private void errorFilterPushDown(LogicalPlan plan, LogicalNode node, FilterPushDownContext context) { String prefix = ""; StringBuilder notMatchedNodeStrBuilder = new StringBuilder(); for (EvalNode notMatchedNode: context.pushingDownFilters) { notMatchedNodeStrBuilder.append(prefix).append(notMatchedNode.toString()); if (prefix.isEmpty()) { prefix = ", "; } } throw new TajoInternalError("FilterPushDown failed cause some filters not matched: " + notMatchedNodeStrBuilder.toString() + "\n" + "Error node: " + node.getPlanString() + "\n" + plan.toString()); } }
@Override public LogicalPlan rewrite(LogicalPlanRewriteRuleContext rewriteRuleContext) throws TajoException { /* FilterPushDown rule: processing when visits each node - If a target which is corresponding on a filter EvalNode's column is not FieldEval, do not PushDown. - Replace filter EvalNode's column with child node's output column. If there is no child node's output column, do not PushDown. - When visit ScanNode, add filter eval to ScanNode's qual - When visit GroupByNode, Find aggregation column in a filter EvalNode and . If a parent is HavingNode, add filter eval to parent HavingNode. . It not, create new HavingNode and set parent's child. */ FilterPushDownContext context = new FilterPushDownContext(); context.rewriteRuleContext = rewriteRuleContext; LogicalPlan plan = rewriteRuleContext.getPlan(); catalog = rewriteRuleContext.getCatalog(); for (LogicalPlan.QueryBlock block : plan.getQueryBlocks()) { context.clear(); this.visit(context, plan, block, block.getRoot(), new Stack<>()); } if (LOG.isDebugEnabled()) { LOG.debug("============================================="); LOG.debug("FilterPushDown Optimized Query: \n" + plan.toString()); LOG.debug("============================================="); } return plan; }
@Override public LogicalPlan rewrite(LogicalPlanRewriteRuleContext rewriteRuleContext) throws TajoException { /* FilterPushDown rule: processing when visits each node - If a target which is corresponding on a filter EvalNode's column is not FieldEval, do not PushDown. - Replace filter EvalNode's column with child node's output column. If there is no child node's output column, do not PushDown. - When visit ScanNode, add filter eval to ScanNode's qual - When visit GroupByNode, Find aggregation column in a filter EvalNode and . If a parent is HavingNode, add filter eval to parent HavingNode. . It not, create new HavingNode and set parent's child. */ FilterPushDownContext context = new FilterPushDownContext(); context.rewriteRuleContext = rewriteRuleContext; LogicalPlan plan = rewriteRuleContext.getPlan(); catalog = rewriteRuleContext.getCatalog(); for (LogicalPlan.QueryBlock block : plan.getQueryBlocks()) { context.clear(); this.visit(context, plan, block, block.getRoot(), new Stack<LogicalNode>()); } if (LOG.isDebugEnabled()) { LOG.debug("============================================="); LOG.debug("FilterPushDown Optimized Query: \n" + plan.toString()); LOG.debug("============================================="); } return plan; }
if (LOG.isDebugEnabled()) { LOG.debug("============================================="); LOG.debug("Non Optimized Query: \n" + plan.toString()); LOG.debug("============================================="); LOG.info("Non Optimized Query: \n" + plan.toString()); optimizer.optimize(queryContext, plan); LOG.info("============================================="); LOG.info("Optimized Query: \n" + plan.toString()); LOG.info("=============================================");
if (LOG.isDebugEnabled()) { LOG.debug("============================================="); LOG.debug("Non Optimized Query: \n" + plan.toString()); LOG.debug("============================================="); LOG.info("Non Optimized Query: \n" + plan.toString()); optimizer.optimize(queryContext, plan); LOG.info("============================================="); LOG.info("Optimized Query: \n" + plan.toString()); LOG.info("=============================================");
private QueryHistory makeQueryHistory() { QueryHistory queryHistory = new QueryHistory(); queryHistory.setQueryId(getId().toString()); queryHistory.setQueryMaster(context.getQueryMasterContext().getWorkerContext().getWorkerName()); queryHistory.setHttpPort(context.getQueryMasterContext().getWorkerContext().getConnectionInfo().getHttpInfoPort()); queryHistory.setLogicalPlan(plan.getLogicalPlan().toString()); queryHistory.setDistributedPlan(plan.toString()); List<String[]> sessionVariables = new ArrayList<String[]>(); for(Map.Entry<String,String> entry: plan.getContext().getAllKeyValus().entrySet()) { if (SessionVars.exists(entry.getKey()) && SessionVars.isPublic(SessionVars.get(entry.getKey()))) { sessionVariables.add(new String[]{entry.getKey(), entry.getValue()}); } } queryHistory.setSessionVariables(sessionVariables); return queryHistory; }
private QueryHistory makeQueryHistory() { QueryHistory queryHistory = new QueryHistory(); queryHistory.setQueryId(getId().toString()); queryHistory.setQueryMaster(context.getQueryMasterContext().getWorkerContext().getWorkerName()); queryHistory.setHttpPort(context.getQueryMasterContext().getWorkerContext().getConnectionInfo().getHttpInfoPort()); queryHistory.setLogicalPlan(plan.getLogicalPlan().toString()); queryHistory.setDistributedPlan(plan.toString()); List<String[]> sessionVariables = new ArrayList<>(); for(Map.Entry<String,String> entry: plan.getContext().getAllKeyValus().entrySet()) { if (SessionVars.exists(entry.getKey()) && SessionVars.isPublic(SessionVars.get(entry.getKey()))) { sessionVariables.add(new String[]{entry.getKey(), entry.getValue()}); } } queryHistory.setSessionVariables(sessionVariables); return queryHistory; }