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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java:
##########
@@ -693,6 +693,20 @@ private LogicalAggregate<? extends Plan> 
storageLayerAggregate(
             return canNotPush;
         }
 
+        // File footers and OLAP zone maps retain only source endpoints. Casts 
that introduce NULL
+        // can discard a valid interior value. Check the cast independently of 
source nullability
+        // so safe widening casts over nullable columns remain eligible. 
Floating sources may have
+        // NaNs omitted by file statistics; DOUBLE/DECIMAL-to-FLOAT can also 
underflow to signed
+        // zero and change the MIN/MAX representative even without introducing 
NULL.
+        if ((functionClasses.contains(Min.class) || 
functionClasses.contains(Max.class))
+                && argumentsOfAggregateFunction.stream().anyMatch(argument -> 
argument instanceof Cast

Review Comment:
   **[P2] Scope representative guards to MIN/MAX arguments**
   
   Once any MIN/MAX is present, this `anyMatch` applies the floating-source and 
DECIMAL-to-FLOAT checks to casts from every aggregate. For a non-null DUP_KEYS 
table, `MIN(int_col), COUNT(CAST(float_col AS DOUBLE))` is an exact OLAP `MIX` 
query: the statistics iterator emits `num_rows` non-null endpoint rows, the 
widening cast cannot create NULL, and only the raw MIN depends on endpoint 
representatives. This arm now rejects the whole rewrite and turns a 
metadata-only aggregation into a full scan. Please preserve 
aggregate-to-argument ownership and scope these two representative checks to 
MIN/MAX arguments, while retaining the NULL-producing check for COUNT casts, 
and cover direct/projected MIX cases.



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