rawsun007 opened a new issue, #11225:
URL: https://github.com/apache/arrow-rs/issues/11225
### Describe the bug
Since #10374 and #10396, the integer and float parsers in `arrow-cast`
accept leading and trailing whitespace, but the `Date32`, `Timestamp` and
`Time64` parsers still reject it. With the default `CastOptions` (`safe: true`)
a padded date or time does not error, it quietly becomes NULL.
### To Reproduce
Casting `StringArray::from(vec![padded, padded.trim()])` with `arrow-cast`
60.0.0:
```
Int32 " 12 " padded null=false | safe=false: ok
Float64 " 1.5 " padded null=false | safe=false: ok
Date32 " 2024-01-05 " padded null=true | safe=false: Cast
error: Cannot cast string ' 2024-01-05 ' to value of Date32 type
Timestamp " 2024-01-05T10:00:00 " padded null=true | safe=false:
Parser error: Error parsing timestamp from ' 2024-01-05T10:00:00 ': error
parsing date
Time64(µs) " 10:00:00 " padded null=true | safe=false: Cast
error: Cannot cast string ' 10:00:00 ' to value of Time64(µs) type
```
The trimmed value parses in every case. `Date32Type::parse` still goes
straight to `parse_date_to_days` on `main`.
Seen through DataFusion `main`: `SELECT CAST(' 12 ' AS INT)` returns 12,
while `SELECT CAST(' 2024-01-05 ' AS DATE)` fails with `Failed to cast field
'lit' from Utf8 to Date32`. PostgreSQL accepts both.
### Expected behavior
The temporal parsers treat surrounding ASCII whitespace the same way the
numeric ones now do.
### Additional context
I'd be happy to send a PR. The shape would follow #10374 and #10396: try the
input as-is first and trim only when that fails, so values without padding take
no extra cost.
Found with Claude Code (Claude Opus 5.5), comparing DataFusion against
PostgreSQL 17. The reproduction above was run here.
--
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]