You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "mingkangli-db (via GitHub)" <gi...@apache.org> on 2023/07/06 13:51:30 UTC

[GitHub] [spark] mingkangli-db commented on a diff in pull request #41843: [SPARK-44280][SQL] Add convertJavaTimestampToTimestamp in JDBCDialect API

mingkangli-db commented on code in PR #41843:
URL: https://github.com/apache/spark/pull/41843#discussion_r1254474150


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala:
##########
@@ -105,10 +105,30 @@ abstract class JdbcDialect extends Serializable with Logging {
    */
   def getJDBCType(dt: DataType): Option[JdbcType] = None
 
+  /**
+   * Converts an instance of `java.sql.Timestamp` to the number of microseconds since
+   * 1970-01-01T00:00:00.000000Z. It extracts date-time fields from the input, builds
+   * a local timestamp in Proleptic Gregorian calendar from the fields, and binds
+   * the timestamp to the system time zone. The resulted instant is converted to
+   * microseconds since the epoch.
+   * JDBC dialects can override this function to provide implementations that suit their
+   * JDBC drivers (e.g. if there are special "infinity" values that would overflow)
+   *
+   * @param t represents a specific instant in time based on
+   *          the hybrid calendar which combines Julian and
+   *          Gregorian calendars.
+   * @return The number of micros since epoch from `java.sql.Timestamp`.
+   * @throws IllegalArgumentException if t is null
+   */
+  def convertJavaTimestampToTimestamp(t: Timestamp): Long = {
+    require(t != null, "timestamp must be non-null")

Review Comment:
   It is not an user facing error but is a precondition: the timestamp passed into this function will never be null. I removed the null check because a similar function `convertJavaTimestampToTimestampNTZ` in JdbcDialects.scala does not have the check either.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org