Skip to content
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

HIVE-25292 : to_unix_timestamp & unix_timestamp should support ENGLIS… #2433

Closed
wants to merge 2 commits into from

Conversation

zzzzming95
Copy link
Contributor

…H format by default

What changes were proposed in this pull request?

update to_unix_timestamp function, Now where the locale of the machine is not in English, the following sql can also return the result correctly:

select to_unix_timestamp('16/Mar/2017:12:25:01 +0800','dd/MMM/yyy:HH:mm:ss Z'); 

Why are the changes needed?

English date is a more common usage, if there is no such patch, in the local non-English environment, the following usage, to_unix_timestamp function will return NULL

hive> select to_unix_timestamp('16/Mar/2017:12:25:01','dd/MMM/yyy:HH:mm:ss');
OK
NULL

Does this PR introduce any user-facing change?

No

How was this patch tested?

To run hive in a non-English environment, the simpler way can use the jvm parameter

-Duser.country=cn -Duser.language=zh

Then run the following sql statement to test, if the timestamp is returned, it is correct.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.

@github-actions github-actions bot added the stale label Aug 26, 2021
@zzzzming95
Copy link
Contributor Author

@kgyrtkirk Could you please review this fix ?

@github-actions
Copy link

github-actions bot commented Dec 6, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.

@github-actions github-actions bot added the stale label Dec 6, 2021
@kgyrtkirk kgyrtkirk removed the stale label Dec 10, 2021
Copy link
Member

@kgyrtkirk kgyrtkirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could probably also consider also adding the US parsing instead of making it the default; what do you think?
so that it will work with the jvm's default locale and with US as well

@zzzzming95
Copy link
Contributor Author

@kgyrtkirk

My initial thoughts were the same as you, but in this way you need to create two DateTimeFormatters, and it seems that you can only use try{} catch{} to control the code logic (or is there a better way ?), which is not very elegant.

Another reason is that I found in Apache Spark that spark to_unix_timestamp udf uses US Local to format the time by default.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.

@github-actions github-actions bot added the stale label Mar 19, 2022
@github-actions github-actions bot closed this Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants