morrySnow commented on code in PR #68134:
URL: https://github.com/apache/doris/pull/68134#discussion_r4043773284


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/MapType.java:
##########
@@ -70,7 +69,9 @@ public boolean isInjectiveCastTo(DataType target) {
             MapType mapType = (MapType) target;
             return keyType.isInjectiveCastTo(mapType.keyType) && 
valueType.isInjectiveCastTo(mapType.valueType);

Review Comment:
   Fixed in 6c72dd0a4da. MapType now reports only exact identity MAP casts as 
injective. The comment documents that every non-identity BE MAP cast calls 
deduplicate_keys(), and the type tests also cover propagation through a nested 
ARRAY<MAP<...>>.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java:
##########
@@ -170,6 +171,20 @@ public boolean isInjectiveCastTo(DataType target) {
             DecimalV3Type decimalV3Type = (DecimalV3Type) target;
             return decimalV3Type.getRange() >= this.getRange() && 
decimalV3Type.getScale() >= this.getScale();
         }
+        // An integral target discards the fractional part, so it is injective 
only for scale zero.
+        // The strict range bound also leaves room for the asymmetric negative 
endpoint of a signed
+        // integer. Binary floating-point casts round, but adjacent values in 
a DECIMAL(P, S) domain
+        // remain distinguishable when P <= 7 for FLOAT or P <= 15 for DOUBLE. 
Those conservative
+        // decimal-digit limits hold for every scale, not just for integral 
decimals.
+        if (scale == 0 && target instanceof IntegralType) {

Review Comment:
   Fixed in 6c72dd0a4da. FE now models DECIMALV2 expression execution as 
DECIMAL(27, 9) for injective checks in both directions and for 
Cast.castNullable, instead of relying on original schema precision/scale. 
Boundary tests cover integral/DECIMALV2, DECIMALV2/DECIMALV3, lossy DECIMALV2 
targets, and nullable inference.



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