maropu commented on a change in pull request #26301: [SPARK-29644] [SQL]
Corrected ShortType and ByteType mapping to SmallInt and TinyInt in JDBCUtils
URL: https://github.com/apache/spark/pull/26301#discussion_r345502337
##########
File path:
external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/MsSqlServerIntegrationSuite.scala
##########
@@ -202,4 +202,46 @@ class MsSqlServerIntegrationSuite extends
DockerJDBCIntegrationSuite {
df2.write.jdbc(jdbcUrl, "datescopy", new Properties)
df3.write.jdbc(jdbcUrl, "stringscopy", new Properties)
}
+
+ test("SPARK-29644: Write tables with ShortType") {
+ import testImplicits._
+ val df = Seq(-32768.toShort, 0.toShort, 1.toShort, 38.toShort,
32768.toShort).toDF("a")
+ val tablename = "shorttable"
+ df.write
+ .format("jdbc")
+ .mode("overwrite")
+ .option("url", jdbcUrl)
+ .option("dbtable", tablename)
+ .save()
+ val df2 = spark.read
+ .format("jdbc")
+ .option("url", jdbcUrl)
+ .option("dbtable", tablename)
+ .load()
+ assert(df.count == df2.count)
+ val rows = df2.collect()
+ val colType = rows(0).toSeq.map(x => x.getClass.toString)
+ assert(colType(0) == "class java.lang.Short")
+ }
+
+ test("SPARK-29644: Write tables with ByteType") {
Review comment:
I think its ok for `JDBCWriteSuite` to only have the two write tests below
for byte and short. So, can you remove the write tests from the integration
tests?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]