sadikovi commented on code in PR #36726:
URL: https://github.com/apache/spark/pull/36726#discussion_r889742470
##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala:
##########
@@ -1879,5 +1880,53 @@ class JDBCSuite extends QueryTest
val fields = schema.fields
assert(fields.length === 1)
assert(fields(0).dataType === StringType)
- }
+ }
+
+ test("SPARK-39339: Handle TimestampNTZType null values") {
+ val tableName = "timestamp_ntz_null_table"
+
+ val df = Seq(null.asInstanceOf[LocalDateTime]).toDF("col1")
+
+ df.write.format("jdbc")
+ .option("url", urlWithUserAndPass)
+ .option("dbtable", tableName).save()
+
+ val res = spark.read.format("jdbc")
+ .option("inferTimestampNTZType", "true")
+ .option("url", urlWithUserAndPass)
+ .option("dbtable", tableName)
+ .load()
+
+ checkAnswer(res, Seq(Row(null)))
+ }
+
+ test("SPARK-39339: TimestampNTZType with different local time zones") {
+ val tableName = "timestamp_ntz_diff_tz_support_table"
+
+ DateTimeTestUtils.outstandingTimezonesIds.foreach { timeZone =>
+ withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> timeZone) {
+ Seq(
+ "1972-07-04 03:30:00",
+ "2019-01-20 12:00:00.502",
+ "2019-01-20T00:00:00.123456",
+ "1500-01-20T00:00:00.123456"
+ ).foreach { case datetime =>
+ val df = spark.sql(s"select timestamp_ntz '$datetime'")
+ df.write.format("jdbc")
+ .mode("overwrite")
+ .option("url", urlWithUserAndPass)
+ .option("dbtable", tableName)
+ .save()
+
+ val res = spark.read.format("jdbc")
+ .option("inferTimestampNTZType", "true")
+ .option("url", urlWithUserAndPass)
+ .option("dbtable", tableName)
+ .load()
Review Comment:
Yes, I will update, thanks 👍.
--
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]