[jira] [Work logged] (HIVE-21633) Estimate range for value generated by aggregate function in statistics annotation

2019-04-26 Thread ASF GitHub Bot (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-21633?focusedWorklogId=233833=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-233833
 ]

ASF GitHub Bot logged work on HIVE-21633:
-

Author: ASF GitHub Bot
Created on: 27/Apr/19 01:32
Start Date: 27/Apr/19 01:32
Worklog Time Spent: 10m 
  Work Description: asfgit commented on pull request #603: HIVE-21633
URL: https://github.com/apache/hive/pull/603
 
 
   
 

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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 233833)
Time Spent: 40m  (was: 0.5h)

> Estimate range for value generated by aggregate function in statistics 
> annotation
> -
>
> Key: HIVE-21633
> URL: https://issues.apache.org/jira/browse/HIVE-21633
> Project: Hive
>  Issue Type: Improvement
>  Components: Statistics
>Reporter: Jesus Camacho Rodriguez
>Assignee: Jesus Camacho Rodriguez
>Priority: Major
>  Labels: pull-request-available
> Attachments: HIVE-21633.02.patch, HIVE-21633.03.patch
>
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> In some cases, we can infer the estimate of the range for a value generated 
> by an aggregate function during statistics annotation. For instance, we can 
> estimate the min of the sum of a column with positive min value as that same 
> min value.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Work logged] (HIVE-21633) Estimate range for value generated by aggregate function in statistics annotation

2019-04-26 Thread ASF GitHub Bot (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-21633?focusedWorklogId=233829=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-233829
 ]

ASF GitHub Bot logged work on HIVE-21633:
-

Author: ASF GitHub Bot
Created on: 27/Apr/19 01:13
Start Date: 27/Apr/19 01:13
Worklog Time Spent: 10m 
  Work Description: vineetgarg02 commented on 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 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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 233829)
Time Spent: 0.5h  (was: 20m)

> Estimate range for value generated by aggregate function in statistics 
> annotation
> -
>
> Key: HIVE-21633
> URL: https://issues.apache.org/jira/browse/HIVE-21633
> Project: Hive
>  Issue Type: Improvement
>  Components: Statistics
>Reporter: Jesus Camacho Rodriguez
>Assignee: Jesus Camacho Rodriguez
>Priority: Major
>  Labels: pull-request-available
> Attachments: HIVE-21633.02.patch, HIVE-21633.03.patch
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> In some cases, we can infer the estimate of the range for a value generated 
> by an aggregate function during statistics annotation. For instance, we can 
> estimate the min of the sum of a column with positive min value as that same 
> min value.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Work logged] (HIVE-21633) Estimate range for value generated by aggregate function in statistics annotation

2019-04-26 Thread ASF GitHub Bot (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-21633?focusedWorklogId=233827=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-233827
 ]

ASF GitHub Bot logged work on HIVE-21633:
-

Author: ASF GitHub Bot
Created on: 27/Apr/19 01:00
Start Date: 27/Apr/19 01:00
Worklog Time Spent: 10m 
  Work Description: vineetgarg02 commented on pull request #603: HIVE-21633
URL: https://github.com/apache/hive/pull/603#discussion_r279137177
 
 

 ##
 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 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:
   Assuming range represent the min,max possible value for the expression is 
this calculation correct?
   Lets say there are 1M numRows and count distinct is 2 and count aggregate is 
distinct, this will set the range to (0,2) but it should be (0, 1/2M).
   No? Or did I miss-understand range
 

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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 233827)
Time Spent: 20m  (was: 10m)

> Estimate range for value generated by aggregate function in statistics 
> annotation
> -
>
> Key: HIVE-21633
> URL: https://issues.apache.org/jira/browse/HIVE-21633
> Project: Hive
>  Issue Type: Improvement
>  Components: Statistics
>Reporter: Jesus Camacho Rodriguez
>Assignee: Jesus Camacho Rodriguez
>Priority: Major
>  Labels: pull-request-available
> Attachments: HIVE-21633.02.patch, HIVE-21633.03.patch
>
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> In some cases, we can infer the estimate of the range for a value generated 
> by an aggregate function during statistics annotation. For instance, we can 
> estimate the min of the sum of a column with positive min value as that same 
> min value.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Work logged] (HIVE-21633) Estimate range for value generated by aggregate function in statistics annotation

2019-04-22 Thread ASF GitHub Bot (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-21633?focusedWorklogId=230823=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-230823
 ]

ASF GitHub Bot logged work on HIVE-21633:
-

Author: ASF GitHub Bot
Created on: 22/Apr/19 18:28
Start Date: 22/Apr/19 18:28
Worklog Time Spent: 10m 
  Work Description: jcamachor commented on pull request #603: HIVE-21633
URL: https://github.com/apache/hive/pull/603
 
 
   
 

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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 230823)
Time Spent: 10m
Remaining Estimate: 0h

> Estimate range for value generated by aggregate function in statistics 
> annotation
> -
>
> Key: HIVE-21633
> URL: https://issues.apache.org/jira/browse/HIVE-21633
> Project: Hive
>  Issue Type: Improvement
>  Components: Statistics
>Reporter: Jesus Camacho Rodriguez
>Assignee: Jesus Camacho Rodriguez
>Priority: Major
>  Labels: pull-request-available
> Attachments: HIVE-21633.02.patch, HIVE-21633.03.patch
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> In some cases, we can infer the estimate of the range for a value generated 
> by an aggregate function during statistics annotation. For instance, we can 
> estimate the min of the sum of a column with positive min value as that same 
> min value.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)