Skip to content

Commit 66dfd4c

Browse files
committed
test fixes
1 parent 395fe99 commit 66dfd4c

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCWriteSuite.scala

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ class JDBCWriteSuite extends SharedSparkSession with BeforeAndAfter {
8989
}
9090

9191
private lazy val arr2x2 = Array[Row](Row.apply("dave", 42), Row.apply("mary", 222))
92-
private lazy val shortarr2x2 = Array[Row](Row.apply("dave", 42.toShort), Row.apply("mary", 31.toShort))
93-
private lazy val bytearr2x2 = Array[Row](Row.apply("dave", 42.toByte), Row.apply("mary", 31.toByte))
9492
private lazy val arr1x2 = Array[Row](Row.apply("fred", 3))
9593
private lazy val schema2 = StructType(
9694
StructField("name", StringType) ::
@@ -106,14 +104,6 @@ class JDBCWriteSuite extends SharedSparkSession with BeforeAndAfter {
106104
StructField("NAME", StringType) ::
107105
StructField("ID", IntegerType) :: Nil)
108106

109-
private lazy val schema5 = StructType(
110-
StructField("NAME", StringType) ::
111-
StructField("ID", ShortType) :: Nil)
112-
113-
private lazy val schema6 = StructType(
114-
StructField("NAME", StringType) ::
115-
StructField("ID", ByteType) :: Nil)
116-
117107
test("Basic CREATE") {
118108
val df = spark.createDataFrame(sparkContext.parallelize(arr2x2), schema2)
119109

@@ -584,8 +574,9 @@ class JDBCWriteSuite extends SharedSparkSession with BeforeAndAfter {
584574
}
585575
}
586576

587-
test("test writing table with ShortType") {
588-
val df = spark.createDataFrame(sparkContext.parallelize(shortarr2x2), schema5)
577+
test("Write tables with ShortType") {
578+
import testImplicits._
579+
val df = Seq(-32768.toShort, 0.toShort, 1.toShort, 38.toShort, 32768.toShort).toDF("a")
589580
val tablename = "shorttable"
590581
df.write
591582
.format("jdbc")
@@ -601,11 +592,12 @@ class JDBCWriteSuite extends SharedSparkSession with BeforeAndAfter {
601592
assert(df.count == df2.count)
602593
val rows = df2.collect()
603594
val colType = rows(0).toSeq.map(x => x.getClass.toString)
604-
assert(colType(1) == "class java.lang.Short")
595+
assert(colType(0) == "class java.lang.Short")
605596
}
606597

607-
test("test writing table with ByteType") {
608-
val df = spark.createDataFrame(sparkContext.parallelize(bytearr2x2), schema6)
598+
test("Write tables with ByteType") {
599+
import testImplicits._
600+
val df = Seq(-127.toByte, 0.toByte, 1.toByte, 38.toByte, 128.toByte).toDF("a")
609601
val tablename = "bytetable"
610602
df.write
611603
.format("jdbc")
@@ -621,7 +613,7 @@ class JDBCWriteSuite extends SharedSparkSession with BeforeAndAfter {
621613
assert(df.count == df2.count)
622614
val rows = df2.collect()
623615
val colType = rows(0).toSeq.map(x => x.getClass.toString)
624-
assert(colType(1) == "class java.lang.Byte")
616+
assert(colType(0) == "class java.lang.Byte")
625617
}
626618

627619
private def runAndVerifyRecordsWritten(expected: Long)(job: => Unit): Unit = {

0 commit comments

Comments
 (0)