-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-22157] [SQL] The uniux_timestamp method handles the time field that is lost in mill #19380
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
srowen
left a comment
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.
I think this has problems in many ways. You're treating dates as doubles and hard-coding some locale-specific concerns. But mostly, this is the wrong answer because the UNIX timestamp is in whole seconds
|
Can one of the admins verify this patch? |
|
In RDMS , unix_timestamp method can keep the milliseconds. For example, execute the command as follows |
| Seq(TypeCollection(StringType, DateType, TimestampType), StringType) | ||
|
|
||
| override def dataType: DataType = LongType | ||
| override def dataType: DataType = DoubleType |
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.
BTW, I think we can't just change this datatype directly. This could break backward compatibility.
|
Since the RDMS keep the milliseconds, we should follow it. This proposal LGTM. @gatorsmile CC |
|
We also have As @HyukjinKwon said, we also need to not break backward compatibility. Btw, for RDMS support, I only found MySQL has direct unix_timestamp support like this. Sounds like not a good idea to break backward compatibility just for following one (or few) RDMS. |
|
This would break compatibility with Spark and other engines like Hive. This shoudl be closed. |
|
In fact, there are many scenarios that need to be accurate to milliseconds, should we try to solve this problem together? |
|
The workaround is to let users write a UDF to handle these cases |
|
I understand everyone's worries.But i hava few thoughts. |
|
Currently, we are following Hive for these built-in functions. See https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF Maybe we can wait and see whether more users have the same requests? Then, we can see whether we should introduce new functions or introduce a SQLConf. |
|
This itself is certainly not a bug. The type is on purpose and certainly the answer is correct given the type. You are arguing for a new function called something else but you can also do this with a UDF |
|
I'd close this for now and optionally we could ask this case and discuss in the mailing list if this is important. |
What changes were proposed in this pull request?
How was this patch tested?
Add new test cases and update existing test cases
Please review http://spark.apache.org/contributing.html before opening a pull request.