diff --git ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java index 186d5809c8..b3a3ba6d1b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java +++ ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java @@ -528,8 +528,6 @@ COLUMNSTATSCOLLECTOR_INVALID_COLUMN(30012, "Column statistics are not supported " + "for partition columns"), - STATISTICS_CLONING_FAILED(30013, "Cloning of statistics failed"), - STATSAGGREGATOR_SOURCETASK_NULL(30014, "SourceTask of StatsTask should not be null"), STATSAGGREGATOR_CONNECTION_ERROR(30015, "Stats aggregator of type {0} cannot be connected to", true), diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java index 9a7badd79e..fcfdce95fc 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java @@ -266,51 +266,48 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, neededCols = tsop.getNeededColumns(); } - try { - if (parentStats != null) { - ExprNodeDesc pred = fop.getConf().getPredicate(); - // evaluate filter expression and update statistics - long newNumRows = evaluateExpression(parentStats, pred, aspCtx, - neededCols, fop, parentStats.getNumRows()); - Statistics st = parentStats.clone(); - - if (satisfyPrecondition(parentStats)) { - - // update statistics based on column statistics. - // OR conditions keeps adding the stats independently, this may - // result in number of rows getting more than the input rows in - // which case stats need not be updated - if (newNumRows <= parentStats.getNumRows()) { - updateStats(st, newNumRows, true, fop); - } + if (parentStats != null) { + ExprNodeDesc pred = fop.getConf().getPredicate(); - if (LOG.isDebugEnabled()) { - LOG.debug("[0] STATS-" + fop.toString() + ": " + st.extendedToString()); - } - } else { + // evaluate filter expression and update statistics + long newNumRows = evaluateExpression(parentStats, pred, aspCtx, + neededCols, fop, parentStats.getNumRows()); + Statistics st = parentStats.clone(); - // update only the basic statistics in the absence of column statistics - if (newNumRows <= parentStats.getNumRows()) { - updateStats(st, newNumRows, false, fop); - } + if (satisfyPrecondition(parentStats)) { - if (LOG.isDebugEnabled()) { - LOG.debug("[1] STATS-" + fop.toString() + ": " + st.extendedToString()); - } + // update statistics based on column statistics. + // OR conditions keeps adding the stats independently, this may + // result in number of rows getting more than the input rows in + // which case stats need not be updated + if (newNumRows <= parentStats.getNumRows()) { + updateStats(st, newNumRows, true, fop); + } + + if (LOG.isDebugEnabled()) { + LOG.debug("[0] STATS-" + fop.toString() + ": " + st.extendedToString()); + } + } else { + + // update only the basic statistics in the absence of column statistics + if (newNumRows <= parentStats.getNumRows()) { + updateStats(st, newNumRows, false, fop); + } + + if (LOG.isDebugEnabled()) { + LOG.debug("[1] STATS-" + fop.toString() + ": " + st.extendedToString()); } - fop.setStatistics(st); - aspCtx.setAndExprStats(null); } - } catch (CloneNotSupportedException e) { - throw new SemanticException(ErrorMsg.STATISTICS_CLONING_FAILED.getMsg()); + fop.setStatistics(st); + aspCtx.setAndExprStats(null); } return null; } protected long evaluateExpression(Statistics stats, ExprNodeDesc pred, AnnotateStatsProcCtx aspCtx, List neededCols, - Operator op, long currNumRows) throws CloneNotSupportedException, SemanticException { + Operator op, long currNumRows) throws SemanticException { long newNumRows = 0; Statistics andStats = null; @@ -495,7 +492,7 @@ private long evaluateInExpr(Statistics stats, ExprNodeDesc pred, long currNumRow } private long evaluateBetweenExpr(Statistics stats, ExprNodeDesc pred, long currNumRows, AnnotateStatsProcCtx aspCtx, - List neededCols, Operator op) throws SemanticException, CloneNotSupportedException { + List neededCols, Operator op) throws SemanticException { final ExprNodeGenericFuncDesc fd = (ExprNodeGenericFuncDesc) pred; final boolean invert = Boolean.TRUE.equals( ((ExprNodeConstantDesc) fd.getChildren().get(0)).getValue()); // boolean invert (not) @@ -528,7 +525,7 @@ private long evaluateBetweenExpr(Statistics stats, ExprNodeDesc pred, long currN private long evaluateNotExpr(Statistics stats, ExprNodeDesc pred, long currNumRows, AnnotateStatsProcCtx aspCtx, List neededCols, Operator op) - throws CloneNotSupportedException, SemanticException { + throws SemanticException { long numRows = currNumRows; @@ -827,7 +824,7 @@ private long evaluateComparator(Statistics stats, ExprNodeGenericFuncDesc genFun private long evaluateChildExpr(Statistics stats, ExprNodeDesc child, AnnotateStatsProcCtx aspCtx, List neededCols, - Operator op, long currNumRows) throws CloneNotSupportedException, SemanticException { + Operator op, long currNumRows) throws SemanticException { long numRows = currNumRows; @@ -1563,12 +1560,8 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, pred = jop.getConf().getResidualFilterExprs().get(0); } // evaluate filter expression and update statistics - try { - newNumRows = evaluateExpression(stats, pred, - aspCtx, jop.getSchema().getColumnNames(), jop, stats.getNumRows()); - } catch (CloneNotSupportedException e) { - throw new SemanticException(ErrorMsg.STATISTICS_CLONING_FAILED.getMsg()); - } + newNumRows = evaluateExpression(stats, pred, + aspCtx, jop.getSchema().getColumnNames(), jop, stats.getNumRows()); // update statistics based on column statistics. // OR conditions keeps adding the stats independently, this may // result in number of rows getting more than the input rows in @@ -1659,12 +1652,8 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, pred = jop.getConf().getResidualFilterExprs().get(0); } // evaluate filter expression and update statistics - try { newNumRows = evaluateExpression(wcStats, pred, aspCtx, jop.getSchema().getColumnNames(), jop, wcStats.getNumRows()); - } catch (CloneNotSupportedException e) { - throw new SemanticException(ErrorMsg.STATISTICS_CLONING_FAILED.getMsg()); - } // update only the basic statistics in the absence of column statistics if (newNumRows <= joinRowCount) { updateStats(wcStats, newNumRows, false, jop);