apache / apache/arrow-rs

Improve error message when formatting with invalid temporal specifiers

Open
#7,153 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
3.6k
Forks
1.3k
Avg merge
2d 18h
Merged PRs (30d)
169

Description

Related to https://github.com/apache/datafusion/issues/14536

`Date` data types should _not_ error when trying to format with time-related specifiers.

For example:
```rust
let array = Date32Array::from(vec![10000, 17890]);

let cast_options = CastOptions {
safe: true,
format_options: FormatOptions::default()
.with_date_format(Some("%Y-%m-%d %H:%M:%S%.6f")),
};

let b = cast_with_options(&array, &DataType::Utf8, &cast_options).unwrap(); // this should not panic
```

Since the temporal-related data types use `chrono` to format, an initial attempt at formatting a `Date` with time-related specifiers will always fail.

If the initial `Date` formatting fails, we should perform an intermediary cast from `Date` to `Timestamp` and reapply the format string.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Date32Array example through cast_with_options with the shown CastOptions, FormatOptions, and DataType::Utf8 values. Read the temporal formatting path and verify that a Date using time-related specifiers no longer panics and produces the expected formatted result after the fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.