shivsood 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_r345536780
 
 

 ##########
 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 both test have their important purpose. JDBCWriteSuite unit test 
will catch any spark regression in CI/CD and integration test are great to 
ensure that functionality works end to end. Consider that ByteType should 
translate to TINYINT in SQLServer, but in PostGres  both ByteType maps to 
SMALLINT. This real distinction is factually verified in Integration test. So i 
think having integration test is very important and thus we should not remove 
these.
   

----------------------------------------------------------------
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]

Reply via email to