vineetgarg02 commented on a change in pull request #603: HIVE-21633
URL: https://github.com/apache/hive/pull/603#discussion_r279137998
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java
##########
@@ -1524,6 +1531,77 @@ public Object process(Node nd, Stack<Node> stack,
NodeProcessorCtx procCtx,
return null;
}
+ /**
+ * If possible, sets the min / max value for the column based on the
aggregate function
+ * being calculated and its input.
+ */
+ private static void computeAggregateColumnMinMax(ColStatistics cs,
HiveConf conf, AggregationDesc agg, String aggType,
+ Statistics parentStats) throws SemanticException {
+ if (agg.getParameters() != null && agg.getParameters().size() == 1) {
+ ColStatistics parentCS = StatsUtils.getColStatisticsFromExpression(
+ conf, parentStats, agg.getParameters().get(0));
+ if (parentCS != null && parentCS.getRange() != null &&
+ parentCS.getRange().minValue != null &&
parentCS.getRange().maxValue != null) {
+ long valuesCount = agg.getDistinct() ?
+ parentCS.getCountDistint() :
+ parentStats.getNumRows() - parentCS.getNumNulls();
+ Range range = parentCS.getRange();
+ // Get the aggregate function matching the name in the query.
+ GenericUDAFResolver udaf =
+
FunctionRegistry.getGenericUDAFResolver(agg.getGenericUDAFName());
+ if (udaf instanceof GenericUDAFCount) {
+ cs.setRange(new Range(0, valuesCount));
Review comment:
Please disregard my previous comment. I confused it with `count with group
by`.
This looks good to me
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]