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

lijibing 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 df5adaafe0c [fix](Nereids)Fix bug of external table didn't set row 
count in StatsCalculator. (#37138)
df5adaafe0c is described below

commit df5adaafe0c575f475bb1c471801aee6f6e3e5cc
Author: Jibing-Li <64681310+jibing...@users.noreply.github.com>
AuthorDate: Wed Jul 3 13:41:50 2024 +0800

    [fix](Nereids)Fix bug of external table didn't set row count in 
StatsCalculator. (#37138)
    
    When build statistic object for external table in LogicalFileScan, we
    didn't set the row count to statistic, cause it always be 0.
---
 .../main/java/org/apache/doris/nereids/stats/StatsCalculator.java   | 2 +-
 .../suites/external_table_p0/hive/test_hive_statistics_p0.groovy    | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

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 f83521ae031..1d26a688990 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
@@ -1049,7 +1049,7 @@ public class StatsCalculator extends 
DefaultPlanVisitor<Statistics, Void> {
             builder.putColumnStatistics(slot, colStatsBuilder.build());
         }
         checkIfUnknownStatsUsedAsKey(builder);
-        return builder.build();
+        return builder.setRowCount(rowCount).build();
     }
 
     private Statistics computeTopN(TopN topN) {
diff --git 
a/regression-test/suites/external_table_p0/hive/test_hive_statistics_p0.groovy 
b/regression-test/suites/external_table_p0/hive/test_hive_statistics_p0.groovy
index bc0275c2f01..cca546cb013 100644
--- 
a/regression-test/suites/external_table_p0/hive/test_hive_statistics_p0.groovy
+++ 
b/regression-test/suites/external_table_p0/hive/test_hive_statistics_p0.groovy
@@ -36,6 +36,12 @@ suite("test_hive_statistics_p0", 
"all_types,p0,external,hive,external_docker,ext
             sql """use `${catalog_name}`.`stats_test`"""
             sql """analyze database stats_test with sync"""
 
+            // Test hive scan node cardinality.
+            sql """analyze table `${catalog_name}`.`statistics`.`statistics` 
with sync"""
+            explain {
+                sql "select count(2) from 
`${catalog_name}`.`statistics`.`statistics`;"
+                contains "cardinality=100"
+            }
 
             def result = sql """show catalog ${catalog_name}"""
             for (int i = 0; i < result.size(); i++) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to