Gustibimo opened a new pull request, #70851:
URL: https://github.com/apache/doris/pull/70851

   ### Background
   
   ExpressionEstimation computes ColumnStatistic for expressions that do not 
produce boolean
   predicates for filtering, such as projected computed columns and GROUP BY 
expressions. When an
   OR or AND expression appears in a projection (e.g. `SELECT a > 1 OR b < 2 AS 
flag`),
   ExpressionEstimation.visitOr and visitAnd estimate the column statistics of 
the boolean result.
   FilterEstimation handles WHERE-clause row-count estimation separately and is 
unaffected.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Enhancement
   
   Problem Summary:
   ExpressionEstimation.visitOr and visitAnd both carried a TODO note about 
their algorithms. They
   computed numNulls using maxNull across child operands (capped at 1) and 
fixed ndv = 2. For OR
   expressions, null occurs only when all operands are null; for AND 
expressions, null occurs when
   at least one operand is null. This PR corrects the numNulls estimation using 
proper null
   probability combinations while keeping ndv = 2 (semantically correct for 
boolean).
   
   ### Details
   
   - **Before and after:** Before, numNulls was estimated as max(numNulls_i, 
1). After, visitOr uses
     rowCount * prod(P(null_i)) and visitAnd uses rowCount * (1 - prod(1 - 
P(null_i))).
   - **Configs and defaults:** None.
   - **Impact on existing users:** None. Only internal column statistics for 
projected boolean
     expressions are affected.
   
   ### Testing
   
   Added unit tests in ExpressionEstimationTest:
   - testOrNullPropagation: verifies product rule for OR numNulls.
   - testAndNullPropagation: verifies inclusion-exclusion rule for AND numNulls.
   - testOrNoNulls: verifies 0 nulls for OR when operands have no nulls.
   - testAndNoNulls: verifies 0 nulls for AND when operands have no nulls.
   
   Note: Full maven test execution could not run locally due to missing 
third-party build toolchain
   (flex/thrift); testing status is partially verified via unit test additions.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: unit tests added in 
ExpressionEstimationTest; local execution blocked by missing thirdparty 
toolchain.
   
   ### AI Disclosure
   
   - Tool: Antigravity
   - Generated: implementation, unit tests, commit message
   - Human review: developer reviewed and confirmed scope and approach
   
   


-- 
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