-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-31896][SQL] Handle am-pm timestamp parsing when hour is missing #28713
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
Conversation
|
cc @cloud-fan @maropu @MaxGekk thanks |
|
Test build #123460 has finished for PR 28713 at commit
|
| accessor.get(ChronoField.HOUR_OF_AMPM) | ||
| } else if (accessor.isSupported(ChronoField.AMPM_OF_DAY) && | ||
| accessor.get(ChronoField.AMPM_OF_DAY) == 1) { | ||
| // When reach here, the `hour` part is missing, the pattern is always contains `a` and minute |
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.
the hour part is missing and PM is specified
|
Test build #123465 has finished for PR 28713 at commit
|
|
retest this please |
|
Test build #123468 has finished for PR 28713 at commit
|
|
Test build #123467 has finished for PR 28713 at commit
|
|
thanks, merging to master/3.0! |
### What changes were proposed in this pull request?
This PR set the hour to 12/0 when the AMPM_OF_DAY field exists
### Why are the changes needed?
When the hour is absent but the am-pm is present, the time is incorrect for pm
### Does this PR introduce _any_ user-facing change?
yes, the change is user-facing but to change back to 2.4 to keep backward compatibility
e.g.
```sql
spark-sql> select to_timestamp('33:33 PM', 'mm:ss a');
1970-01-01 12:33:33
spark-sql> select to_timestamp('33:33 AM', 'mm:ss a');
1970-01-01 00:33:33
```
otherwise, the results are all `1970-01-01 00:33:33`
### How was this patch tested?
add unit tests
Closes #28713 from yaooqinn/SPARK-31896.
Authored-by: Kent Yao <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit afcc14c)
Signed-off-by: Wenchen Fan <[email protected]>
|
Test build #123481 has finished for PR 28713 at commit
|
What changes were proposed in this pull request?
This PR set the hour to 12/0 when the AMPM_OF_DAY field exists
Why are the changes needed?
When the hour is absent but the am-pm is present, the time is incorrect for pm
Does this PR introduce any user-facing change?
yes, the change is user-facing but to change back to 2.4 to keep backward compatibility
e.g.
otherwise, the results are all
1970-01-01 00:33:33How was this patch tested?
add unit tests