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


##########
arrow-cast/src/cast/string.rs:
##########
@@ -112,8 +112,11 @@ fn cast_string_to_timestamp_impl<O: OffsetSizeTrait, T: 
ArrowTimestampType, Tz:
             .map(|v| {
                 v.map(|v| {
                     let naive = string_to_datetime(tz, v)?.naive_utc();
-                    T::make_value(naive).ok_or_else(|| {
-                        ArrowError::CastError(format!(
+                    T::make_value(naive).ok_or_else(|| match T::UNIT {
+                        TimeUnit::Nanosecond => ArrowError::CastError(format!(

Review Comment:
   I tried
   
   ```rust
       let  a  = Arc::new(TimestampMicrosecondArray::from(vec![Some(i64::MIN), 
Some(i64::MAX)]));
       println!("{}", pretty_format_columns("foo", &[a]).unwrap());
   ```
   
   And I got 
   ```
   
+--------------------------------------------------------------------------------------------------------+
   | foo                                                                        
                            |
   
+--------------------------------------------------------------------------------------------------------+
   | ERROR: Cast error: Failed to convert -9223372036854775808 to datetime for 
Timestamp(Microsecond, None) |
   | ERROR: Cast error: Failed to convert 9223372036854775807 to datetime for 
Timestamp(Microsecond, None)  |
   
+--------------------------------------------------------------------------------------------------------+
   ```
   
   So if you can figure out the min/max values that were allowed for that type 
and then that code would show you the string value I think
   
   However, to be honest what we have in this PR is better than main, I think 
we could merge it as is
   



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