| 1389 | impl<'a> TryFrom<&'a FormatOptions> for arrow::util::display::FormatOptions<'a> { |
| 1390 | type Error = DataFusionError; |
| 1391 | fn try_from(options: &'a FormatOptions) -> Result<Self> { |
| 1392 | let duration_format = match options.duration_format.as_str() { |
| 1393 | "pretty" => arrow::util::display::DurationFormat::Pretty, |
| 1394 | "iso8601" => arrow::util::display::DurationFormat::ISO8601, |
| 1395 | _ => { |
| 1396 | return _config_err!( |
| 1397 | "Invalid duration format: {}. Valid values are pretty or iso8601", |
| 1398 | options.duration_format |
| 1399 | ); |
| 1400 | } |
| 1401 | }; |
| 1402 | |
| 1403 | Ok(Self::new() |
| 1404 | .with_display_error(options.safe) |
| 1405 | .with_null(&options.null) |
| 1406 | .with_date_format(options.date_format.as_deref()) |
| 1407 | .with_datetime_format(options.datetime_format.as_deref()) |
| 1408 | .with_timestamp_format(options.timestamp_format.as_deref()) |
| 1409 | .with_timestamp_tz_format(options.timestamp_tz_format.as_deref()) |
| 1410 | .with_time_format(options.time_format.as_deref()) |
| 1411 | .with_duration_format(duration_format) |
| 1412 | .with_types_info(options.types_info)) |
| 1413 | } |
| 1414 | } |
| 1415 | |
| 1416 | /// A key value pair, with a corresponding description |