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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java:
##########
@@ -218,13 +219,29 @@ private static DataType widerDecimalV3Type(
     @Override
     public boolean isInjectiveCastTo(DataType target) {
         if (target instanceof DecimalV2Type) {
-            DecimalV2Type decimalV2Type = (DecimalV2Type) target;
-            return decimalV2Type.getRange() >= this.getRange() && 
decimalV2Type.getScale() >= this.getScale();
+            // BE evaluates every DECIMALV2 target as DECIMAL(27, 9); its 
declared schema
+            // precision and scale do not restrict values produced by 
expression evaluation.
+            return DecimalV2Type.EXECUTION_RANGE >= getRange()

Review Comment:
   **[P2] Keep unimplemented V3-to-V2 casts out of elimination**
   
   This newly returns `true` for pairs such as `DECIMALV3(3,1) -> 
DECIMALV2(2,0)`, but BE cannot execute that cast: the purported V3-to-V2 
specialization requires `ToDataType` to be both V3 and V2, so the primary 
`CastToImpl` returns `not support`.
   
   For aggregate-only keys such as `CAST(CAST(x AS DECIMALV2(2,0)) AS 
DECIMALV3(27,9)) * 1.0` and the same expression multiplied by `2.0`, 
`SimplifyAggGroupBy.canExtractSlot` peels the supported outer cast and then 
this newly accepted inner cast. Both keys become bare `x`, and because the 
output is only `count(*)`, the unsupported casts disappear. The change 
therefore turns a deterministic runtime failure into successful results. Please 
keep this route false until BE implements it (or make the consumer prove total 
executability), and add an end-to-end aggregate regression.



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