You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "okumin (via GitHub)" <gi...@apache.org> on 2023/05/24 11:47:31 UTC

[GitHub] [hive] okumin commented on a diff in pull request #4353: [WIP, Don't review] HIVE-24240: Implement missing features in UDTFStatsRule

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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org