shrivasshankar commented on code in PR #27148:
URL: https://github.com/apache/datafusion/pull/27148#discussion_r4516398469


##########
datafusion/physical-expr/src/expressions/cast.rs:
##########
@@ -699,6 +699,28 @@ fn can_propagate_cast_constraints(source: &DataType, 
target: &DataType) -> bool
         || (source.is_integer() && target.is_integer())
         // NaN bounds are unbounded; finite Float32 values widen exactly.
         || (*source == Float32 && *target == Float64)
+        || is_decimal_widening(source, target)
+}
+
+/// Whether a decimal-to-decimal cast keeps every value exactly, i.e. the 
target
+/// has at least as many fractional and integer digits as the source. Casting
+/// bounds back to the source then rounds to a neighboring representable value,
+/// which never excludes a valid input.
+fn is_decimal_widening(source: &DataType, target: &DataType) -> bool {

Review Comment:
   I moved it into a shared is_lossless_decimal_cast helper. i < 2.5 now 
estimates 33.



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