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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new dcfc72bb367 [fix](nereids) bug: after is-null stats derive, other 
column stats are dropped (#37809) (#38024)
dcfc72bb367 is described below

commit dcfc72bb367e28cab58d576d858ab45dd106fd5c
Author: minghong <[email protected]>
AuthorDate: Thu Jul 18 08:11:09 2024 +0800

    [fix](nereids) bug: after is-null stats derive, other column stats are 
dropped (#37809) (#38024)
    
    ## Proposed changes
    pick from #37809
    Issue Number: close #xxx
    
    <!--Describe your changes.-->
---
 .../java/org/apache/doris/nereids/stats/StatsCalculator.java  | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 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 9eed99f08da..cb7177569e6 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
@@ -625,17 +625,24 @@ public class StatsCalculator extends 
DefaultPlanVisitor<Statistics, Void> {
                 Statistics isNullStats = 
computeGeneratedIsNullStats((LogicalJoin) plan, filter);
                 if (isNullStats != null) {
                     // overwrite the stats corrected as above before passing 
to filter estimation
-                    stats = isNullStats;
                     Set<Expression> newConjuncts = 
filter.getConjuncts().stream()
                             .filter(e -> !(e instanceof IsNull))
                             .collect(Collectors.toSet());
                     if (newConjuncts.isEmpty()) {
-                        return stats;
+                        return isNullStats;
                     } else {
                         // overwrite the filter by removing is null and remain 
the others
                         filter = ((LogicalFilter<?>) 
filter).withConjunctsAndProps(newConjuncts,
                                 ((LogicalFilter<?>) 
filter).getGroupExpression(),
                                 Optional.of(((LogicalFilter<?>) 
filter).getLogicalProperties()), plan);
+                        // add update is-null related column stats for other 
predicate derive
+                        StatisticsBuilder builder = new 
StatisticsBuilder(stats);
+                        for (Expression expr : 
isNullStats.columnStatistics().keySet()) {
+                            builder.putColumnStatistics(expr, 
isNullStats.findColumnStatistics(expr));
+                        }
+                        builder.setRowCount(isNullStats.getRowCount());
+                        stats = builder.build();
+                        stats.enforceValid();
                     }
                 }
             }


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

Reply via email to