haohuaijin commented on code in PR #25227:
URL: https://github.com/apache/datafusion/pull/25227#discussion_r3999343833


##########
datafusion/physical-expr/src/expressions/cast.rs:
##########
@@ -249,8 +249,11 @@ impl CastExpr {
         })
     }
 
-    /// Check if casting from the specified source type to the target type is a
-    /// widening cast (e.g. from `Int8` to `Int16`).
+    /// Check if casting from the source type to the target type is known to be
+    /// lossless and strictly order-preserving for all source values, 
preserving nulls.
+    /// This includes widening casts (e.g. `Int8` to `Int16`) and 
representation
+    /// conversions such as `Int32` to `Date32`, which interprets the same 
integer
+    /// as days since the epoch.
     pub fn check_bigger_cast(cast_type: &DataType, src: &DataType) -> bool {
         if cast_type.eq(src) {
             return true;

Review Comment:
   We can extend this helper in a follow-up to recognize more safe conversions, 
such as `UInt32` → `Int64`, allowing statistics to be preserved without 
requiring exact bounds on both ends.



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