github-actions[bot] commented on code in PR #69817:
URL: https://github.com/apache/doris/pull/69817#discussion_r4422073451


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java:
##########
@@ -1047,6 +1066,7 @@ private Statistics estimateColumnEqualToColumn(Expression 
leftExpr, ColumnStatis
                 * (keepNull ? 1 : leftNotNullSel * rightNotNullSel);
 
         Statistics updatedStatistics = context.statistics.withSel(notNullSel, 
numNull);
+        updatedStatistics.rescaleNumNulls(context.statistics.getRowCount());

Review Comment:
   [P2] Preserve key-stat validity before estimating OR overlaps
   
   This call validates the copied key statistics, but `addColumnStats` below 
restores `intersectBuilder`'s larger NDVs afterward. With OR's child 
normalization removed, a reduced plan `Filter((a = b) OR (a <=> b)) -> Scan(a, 
b)` over schema-nullable columns with 1,000 input rows, NDV 1,000, ranges [1, 
1000], and zero measured NULLs returns a one-row left branch whose key NDVs are 
still 1,000. `visitOr` then estimates the overlap as 0.001 and the union as 
1.999 rows, instead of the previous 1 row, even though the normal-equality 
branch is a subset of the null-safe branch. Both nullable operands keep this 
expression from being simplified to duplicate equalities. Enforce validity 
after the key overrides, or on OR children without rescaling again; the final 
`enforceValid()` cannot repair an already-computed union row count.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to