@@ -73,28 +73,19 @@ class DataFrameComplexTypeSuite extends QueryTest with SharedSparkSession {
7373
7474 test(" SPARK-29503 nest unsafe struct inside safe array" ) {
7575 withSQLConf(SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> " false" ) {
76- val exampleDS = spark.sparkContext.parallelize(Seq (Seq (1 , 2 , 3 ))).toDF(" items" )
76+ val df = spark.sparkContext.parallelize(Seq (Seq (1 , 2 , 3 ))).toDF(" items" )
7777
7878 // items: Seq[Int] => items.map { item => Seq(Struct(item)) }
79- val result = exampleDS .select(
79+ val result = df .select(
8080 new Column (MapObjects (
8181 (item : Expression ) => array(struct(new Column (item))).expr,
8282 $" items" .expr,
83- exampleDS .schema(" items" ).dataType.asInstanceOf [ArrayType ].elementType
83+ df .schema(" items" ).dataType.asInstanceOf [ArrayType ].elementType
8484 )) as " items"
8585 ).collect()
8686
87- def getValueInsideDepth (result : Row , index : Int ): Int = {
88- // expected output:
89- // WrappedArray([WrappedArray(WrappedArray([1]), WrappedArray([2]), WrappedArray([3]))])
90- result.getSeq[mutable.WrappedArray [_]](0 )(index)(0 )
91- .asInstanceOf [GenericRowWithSchema ].getInt(0 )
92- }
93-
9487 assert(result.size === 1 )
95- assert(getValueInsideDepth(result.head, 0 ) === 1 )
96- assert(getValueInsideDepth(result.head, 1 ) === 2 )
97- assert(getValueInsideDepth(result.head, 2 ) === 3 )
88+ assert(result === Row (Seq (Seq (Row (1 )), Seq (Row (2 )), Seq (Row (3 )))) :: Nil )
9889 }
9990 }
10091}
0 commit comments