okumin commented on code in PR #4353:
URL: https://github.com/apache/hive/pull/4353#discussion_r1203955752


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java:
##########
@@ -3066,27 +3066,23 @@ public Object process(Node nd, Stack<Node> stack, 
NodeProcessorCtx procCtx,
       if (parentStats != null) {
         Statistics st = parentStats.clone();
 
-        float udtfFactor=HiveConf.getFloatVar(aspCtx.getConf(), 
HiveConf.ConfVars.HIVE_STATS_UDTF_FACTOR);
-        long numRows = (long) (parentStats.getNumRows() * udtfFactor);
+        float udtfFactor = HiveConf.getFloatVar(aspCtx.getConf(), 
HiveConf.ConfVars.HIVE_STATS_UDTF_FACTOR);
+        long numRows = Math.max(StatsUtils.safeMult(parentStats.getNumRows(), 
udtfFactor), 1);

Review Comment:
   This change happened on [this 
discussion](https://github.com/apache/hive/pull/1531#discussion_r500420813) 
with @kgyrtkirk.
   [Hive's stats will degrade when the number of rows or data size becomes 
zero](https://github.com/apache/hive/blob/rel/release-4.0.0-alpha-2/ql/src/java/org/apache/hadoop/hive/ql/plan/Statistics.java#L111-L119).
 So, it is better to keep one row so that Hive can apply full optimization. 
Ideally, we should explicitly distinguish empty stats from missing stats.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to