-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
[SPARK-47501][SQL] Add convertDateToDate like the existing convertTimestampToTimestamp for JdbcDialect #45638
Conversation
…estampToTimestamp for JdbcDialect
@@ -307,24 +307,23 @@ private object PostgresDialect extends JdbcDialect with SQLConfHelper { | |||
override def convertJavaTimestampToTimestamp(t: Timestamp): Timestamp = { | |||
// Variable names come from PostgreSQL "constant field docs": | |||
// https://jdbc.postgresql.org/documentation/publicapi/index.html?constant-values.html | |||
val POSTGRESQL_DATE_NEGATIVE_INFINITY = -9223372036832400000L | |||
val POSTGRESQL_DATE_NEGATIVE_SMALLER_INFINITY = -185543533774800000L |
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.
*_SMALLER_INFINITY
s are for PgResultSet to identify date infinities internally, they are supplanted with the larger abs-values to clients
cc @cloud-fan @dongjoon-hyun @mingkangli-db, thanks |
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.
+1, LGTM. Merged to master.
Thank you @dongjoon-hyun |
* @return the date value after conversion | ||
*/ | ||
@Since("4.0.0") | ||
def convertDateToDate(d: Date): Date = d |
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.
for name consistency, should this be convertJavaDateToDate
?
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.
Oh, thanks. +1 for the above new name.
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 for being so careful. And sorry for my carelessness
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.
To fix my mistake, I sent #45656. Please help review when you have some time
…estampToTimestamp for JdbcDialect ### What changes were proposed in this pull request? Add convertDateToDate like the existing convertTimestampToTimestamp for JdbcDialect ### Why are the changes needed? The date '±infinity' values cause overflows like timestamp '±infinity' in apache#41843 ### Does this PR introduce _any_ user-facing change? fix expected overflow for dates to align with the timestamps of PostgreSQL ### How was this patch tested? new tests ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#45638 from yaooqinn/SPARK-47501. Authored-by: Kent Yao <yao@apache.org> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
What changes were proposed in this pull request?
Add convertDateToDate like the existing convertTimestampToTimestamp for JdbcDialect
Why are the changes needed?
The date '±infinity' values cause overflows like timestamp '±infinity' in #41843
Does this PR introduce any user-facing change?
fix expected overflow for dates to align with the timestamps of PostgreSQL
How was this patch tested?
new testsWas this patch authored or co-authored using generative AI tooling?
no