@@ -34,6 +34,8 @@ import org.apache.spark.sql.hive.test.TestHive.implicits._
34
34
import org .apache .spark .sql .parquet .ParquetRelation2
35
35
import org .apache .spark .sql .sources .LogicalRelation
36
36
37
+ import scala .collection .mutable .ArrayBuffer
38
+
37
39
/**
38
40
* Tests for persisting tables created though the data sources API into the metastore.
39
41
*/
@@ -596,12 +598,23 @@ class MetastoreDataSourcesSuite extends QueryTest with BeforeAndAfterEach {
596
598
test(" Pre insert nullability check" ) {
597
599
val df1 =
598
600
createDataFrame(Tuple1 (Seq (Int .box(1 ), null .asInstanceOf [Integer ])) :: Nil ).toDF(" a" )
601
+ val expectedSchema1 =
602
+ StructType (
603
+ StructField (" a" , ArrayType (IntegerType , containsNull = true ), nullable = true ) :: Nil )
604
+ assert(df1.schema === expectedSchema1)
599
605
df1.saveAsTable(" arrayInParquet" , " parquet" , SaveMode .Overwrite )
600
606
601
607
val df2 =
602
608
createDataFrame(Tuple1 (Seq (2 , 3 )) :: Nil ).toDF(" a" )
609
+ val expectedSchema2 =
610
+ StructType (
611
+ StructField (" a" , ArrayType (IntegerType , containsNull = false ), nullable = true ) :: Nil )
612
+ assert(df2.schema === expectedSchema2)
603
613
df2.saveAsTable(" arrayInParquet" , SaveMode .Append )
604
614
615
+ checkAnswer(
616
+ sql(" SELECT a FROM arrayInParquet" ),
617
+ Row (ArrayBuffer (1 , null )) :: Row (ArrayBuffer (2 , 3 )) :: Nil )
605
618
}
606
619
607
620
test(" SPARK-6024 wide schema support" ) {
0 commit comments