alamb commented on code in PR #5764:
URL: https://github.com/apache/arrow-datafusion/pull/5764#discussion_r1153265676
##########
datafusion/common/src/scalar.rs:
##########
@@ -1011,18 +1011,82 @@ fn ts_sub_to_interval<const TIME_MOD: bool>(
}
}
-// This function parses the timezone from string to Tz.
-// If it cannot parse or timezone field is [`None`], it returns [`None`].
-pub fn parse_timezones(tz: &Option<String>) -> Option<Tz> {
+/// This function parses the timezone from string to Tz.
+/// If it cannot parse or timezone field is [`None`], it returns [`None`].
+pub fn parse_timezones(tz: &Option<String>) -> Result<Option<Tz>> {
if let Some(tz) = tz {
- let parsed_tz: Option<Tz> = FromStr::from_str(tz)
- .map_err(|_| {
- DataFusionError::Execution("cannot parse given
timezone".to_string())
- })
- .ok();
- parsed_tz
+ let parsed_tz: Tz = FromStr::from_str(tz).map_err(|_| {
+ DataFusionError::Execution("cannot parse given
timezone".to_string())
Review Comment:
It would be nice if the error contained the problematic timezone. Something
like
```rust
let parsed_tz: Tz = FromStr::from_str(tz).map_err(|e| {
DataFusionError::Execution(format!("cannot parse '{tz}' as
timezone: {e}".to_string())
```
--
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]