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

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


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

commit 74691b73adc5648535b2928863dbcb7496185034
Author: minghong <engle...@gmail.com>
AuthorDate: Mon Jul 15 18:56:24 2024 +0800

    [fix](nereids) bug: after is-null stats derive, other column stats are 
dropped #37809 (#37832)
    
    ## Proposed changes
    pick #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 f83521ae031..8785be7eb93 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
@@ -829,17 +829,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: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to