alamb commented on code in PR #5114:
URL: https://github.com/apache/arrow-rs/pull/5114#discussion_r1406025789


##########
arrow-cast/src/cast.rs:
##########
@@ -692,9 +668,9 @@ fn as_time_res_with_timezone<T: ArrowPrimitiveType>(
     })
 }
 
-/// Cast `array` to the provided data type and return a new Array with
-/// type `to_type`, if possible. It accepts `CastOptions` to allow consumers
-/// to configure cast behavior.
+/// Cast `array` to the provided data type and return a new Array with type 
`to_type`, if possible.
+///
+/// Accepts [`CastOptions`] to allow configuring the cast behavior.
 ///
 /// Behavior:

Review Comment:
   ```suggestion
   /// ## Behavior
   ```



##########
arrow-cast/src/cast.rs:
##########
@@ -704,15 +680,21 @@ fn as_time_res_with_timezone<T: ArrowPrimitiveType>(
 ///   in integer casts return null
 /// * Numeric to boolean: 0 returns `false`, any other value returns `true`
 /// * List to List: the underlying data type is cast
+/// * List to FixedSizeList: the underlying data type is cast. If safe is true 
and a list element
+/// has the wrong length it will be replaced with NULL, otherwise an error 
will be returned

Review Comment:
   The documentation on `CastOptions` is pretty good
   
   ```suggestion
   /// * List to FixedSizeList: the underlying data type is cast. If the list 
element
   /// has the wrong length it will either be replaced with NULL, or an error 
will be returned depending on the
   /// value of [`CastOptions::safe`]. 
   ```



##########
arrow-cast/src/cast.rs:
##########
@@ -272,32 +271,9 @@ pub fn can_cast_types(from_type: &DataType, to_type: 
&DataType) -> bool {
     }
 }
 
-/// Cast `array` to the provided data type and return a new Array with
-/// type `to_type`, if possible.
+/// Cast `array` to the provided data type and return a new Array with type 
`to_type`, if possible.
 ///
-/// Behavior:

Review Comment:
   The link to `cast_with_options` is a good idea



##########
arrow-cast/src/cast.rs:
##########
@@ -704,15 +680,21 @@ fn as_time_res_with_timezone<T: ArrowPrimitiveType>(
 ///   in integer casts return null
 /// * Numeric to boolean: 0 returns `false`, any other value returns `true`
 /// * List to List: the underlying data type is cast
+/// * List to FixedSizeList: the underlying data type is cast. If safe is true 
and a list element
+/// has the wrong length it will be replaced with NULL, otherwise an error 
will be returned
 /// * Primitive to List: a list array with 1 value per slot is created
 /// * Date32 and Date64: precision lost when going to higher interval
 /// * Time32 and Time64: precision lost when going to higher interval
 /// * Timestamp and Date{32|64}: precision lost when going to higher interval
 /// * Temporal to/from backing primitive: zero-copy with data type change
+/// * Casting from `float32/float64` to `Decimal(precision, scale)` rounds to 
the `scale` decimals

Review Comment:
   ```suggestion
   /// * Casting from `float32/float64` to `Decimal(precision, scale)` rounds 
to `scale` decimals
   ```



##########
arrow-cast/src/cast.rs:
##########
@@ -704,15 +680,21 @@ fn as_time_res_with_timezone<T: ArrowPrimitiveType>(
 ///   in integer casts return null
 /// * Numeric to boolean: 0 returns `false`, any other value returns `true`
 /// * List to List: the underlying data type is cast
+/// * List to FixedSizeList: the underlying data type is cast. If safe is true 
and a list element
+/// has the wrong length it will be replaced with NULL, otherwise an error 
will be returned
 /// * Primitive to List: a list array with 1 value per slot is created
 /// * Date32 and Date64: precision lost when going to higher interval
 /// * Time32 and Time64: precision lost when going to higher interval
 /// * Timestamp and Date{32|64}: precision lost when going to higher interval
 /// * Temporal to/from backing primitive: zero-copy with data type change
+/// * Casting from `float32/float64` to `Decimal(precision, scale)` rounds to 
the `scale` decimals
+///   (i.e. casting 6.4999 to Decimal(10, 1) becomes 6.5). This is a breaking 
change from `26.0.0`.
+///   It used to truncate it instead of round (i.e. outputs 6.4 instead)

Review Comment:
   ```suggestion
   ///   (i.e. casting `6.4999` to Decimal(10, 1) becomes `6.5`). Prior to  
version `26.0.0`, 
   ///   casting would truncate instead (i.e. outputs `6.4` instead)
   ```



##########
arrow-cast/src/cast.rs:
##########
@@ -692,9 +668,9 @@ fn as_time_res_with_timezone<T: ArrowPrimitiveType>(
     })
 }
 
-/// Cast `array` to the provided data type and return a new Array with
-/// type `to_type`, if possible. It accepts `CastOptions` to allow consumers
-/// to configure cast behavior.
+/// Cast `array` to the provided data type and return a new Array with type 
`to_type`, if possible.
+///
+/// Accepts [`CastOptions`] to allow configuring the cast behavior.

Review Comment:
   ```suggestion
   /// Accepts [`CastOptions`] to specify cast behavior.
   ```



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

Reply via email to