-
Notifications
You must be signed in to change notification settings - Fork 847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Added support to cast string without time #3494
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
It would be better if you can add this into accepted input format of the doc of string_to_timestamp_nanos
.
3d413c4
to
ff7a32a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @csphile and @viirya
Would it be possible to also update the doc comment's "Examples of accepted inputs" to include this as well?
🤔 there appears to be a test failure: https://github.com/apache/arrow-rs/actions/runs/3872149018/jobs/6603268102
|
Fixed, I think adding "00:00:00" is necessary since NaiveDateTime::parse_from_str cannot accept %Y-%m-%d |
arrow-cast/src/parse.rs
Outdated
if let Ok(ts) = | ||
NaiveDateTime::parse_from_str(&format!("{} 00:00:00", s), "%Y-%m-%d %H:%M:%S") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allocates a new string which might take some serious time -- perhaps it would be possible to parse using NaiveDate
and then convert the NaiveDate to a NaiveDateTime ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. PTAL
d919414
to
f6807e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome -- thank you so much @csphile and @viirya
// without a timezone specifier as a local time, only date | ||
// Example: 2020-09-08 | ||
if let Ok(dt) = NaiveDate::parse_from_str(s, "%Y-%m-%d") { | ||
if let Some(ts) = dt.and_hms_opt(0, 0, 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Benchmark runs are scheduled for baseline = 592d7a3 and contender = fb36dd9. fb36dd9 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Which issue does this PR close?
Closes #3492
Rationale for this change
Support cast string like 2022-01-08
What changes are included in this PR?
arrow-rs/arrow-cast/src/parse.rs
Are there any user-facing changes?
No