liukun4515 commented on code in PR #3267:
URL: https://github.com/apache/arrow-rs/pull/3267#discussion_r1039130772


##########
arrow-cast/src/cast.rs:
##########
@@ -4271,6 +4316,63 @@ mod tests {
             cast_with_options(&array, &DataType::Int8, &CastOptions { safe: 
true });
         assert!(casted_array.is_ok());
         assert!(casted_array.unwrap().is_null(0));
+
+        // loss the precision: convert decimal to f32、f64
+        // f32
+        // 112345678_f32 and 112345679_f32 are same, so the 112345679_f32 will 
lose precision.
+        let value_array: Vec<Option<i256>> = vec![
+            Some(i256::from_i128(125)),
+            Some(i256::from_i128(225)),
+            Some(i256::from_i128(325)),
+            None,
+            Some(i256::from_i128(525)),
+            Some(i256::from_i128(112345678)),
+            Some(i256::from_i128(112345679)),
+        ];
+        let decimal_array = create_decimal256_array(value_array, 76, 
2).unwrap();
+        let array = Arc::new(decimal_array) as ArrayRef;
+        generate_cast_test_case!(
+            &array,
+            Float32Array,
+            &DataType::Float32,
+            vec![
+                Some(1.25_f32),
+                Some(2.25_f32),
+                Some(3.25_f32),
+                None,
+                Some(5.25_f32),
+                Some(1_123_456.7_f32),
+                Some(1_123_456.7_f32)

Review Comment:
   👍



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