tianhanhu-db commented on code in PR #40678:
URL: https://github.com/apache/spark/pull/40678#discussion_r1160377729


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala:
##########
@@ -104,6 +105,23 @@ abstract class JdbcDialect extends Serializable with 
Logging {
    */
   def getJDBCType(dt: DataType): Option[JdbcType] = None
 
+  /**
+   * Convert java.sql.Timestamp to a Long value (internal representation of a 
TimestampNTZType)
+   * holding the microseconds since the epoch of 1970-01-01 00:00:00Z for this 
timestamp.
+   */
+  def convertJavaTimestampToTimestampNTZ(t: Timestamp): Long = {
+    DateTimeUtils.fromJavaTimestampNoRebase(t)
+  }
+
+  /**
+   * Converts a LocalDateTime representing a TimestampNTZ type to an
+   * instance of `java.sql.Timestamp`.
+   */
+  def convertTimestampNTZToJavaTimestamp(ldt: LocalDateTime): Timestamp = {

Review Comment:
   It would be hard to make them symmetric actually.
   For example, the neutral conversion solution here stores the Java 
Timestamp's underlining microseconds from epoch directly into the long value. 
It would be wrong to construct a `LocalDateTime` from the year, day, ..., 
minute, second fields in the Timestamp.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to