This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 02149ff329 [fix](nereids) Agg on unknown-stats column (#21428)
02149ff329 is described below

commit 02149ff329f6280cc5eaecc9a8b3f7eef3604ad4
Author: minghong <[email protected]>
AuthorDate: Fri Jul 7 17:03:04 2023 +0800

    [fix](nereids) Agg on unknown-stats column (#21428)
---
 .../java/org/apache/doris/nereids/stats/StatsCalculator.java   | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java
index 385c0227ea..da6af46376 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java
@@ -680,11 +680,13 @@ public class StatsCalculator extends 
DefaultPlanVisitor<Statistics, Void> {
         }
         int groupByCount = groupByExpressions.size();
         if 
(groupByColStats.values().stream().anyMatch(ColumnStatistic::isUnKnown)) {
+            // if there is group-bys, output row count is 
childStats.getRowCount() * DEFAULT_AGGREGATE_RATIO,
+            // o.w. output row count is 1
+            // example: select sum(A) from T;
             if (groupByCount > 0) {
-                rowCount *= DEFAULT_AGGREGATE_RATIO * 
Math.pow(DEFAULT_AGGREGATE_EXPAND_RATIO, groupByCount - 1);
-            }
-            if (rowCount > childStats.getRowCount()) {
-                rowCount = childStats.getRowCount();
+                rowCount = childStats.getRowCount() * DEFAULT_AGGREGATE_RATIO;
+            } else {
+                rowCount = 1;
             }
         } else {
             if (groupByCount > 0) {


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

Reply via email to