@@ -830,6 +830,7 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
830830
831831 test(" SPARK-22500: cast for struct should not generate codes beyond 64KB" ) {
832832 val N = 1000
833+ val M = 250
833834
834835 val from1 = new StructType (
835836 (1 to N ).map(i => StructField (s " s $i" , StringType )).toArray)
@@ -856,5 +857,19 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
856857 val input3 = Row .fromSeq((1 to N ).map(i => Row (i)))
857858 val output3 = Row .fromSeq((1 to N ).map(i => Row (i.toLong)))
858859 checkEvaluation(cast(Literal .create(input3, from3), to3), output3)
860+
861+ val fromInner = new StructType (
862+ (1 to M ).map(i => StructField (s " s $i" , DoubleType )).toArray)
863+ val toInner = new StructType (
864+ (1 to M ).map(i => StructField (s " i $i" , IntegerType )).toArray)
865+ val inputInner = Row .fromSeq((1 to M ).map(i => i + 0.5 ))
866+ val outputInner = Row .fromSeq((1 to M ))
867+ val fromOuter = new StructType (
868+ (1 to M ).map(i => StructField (s " s $i" , fromInner)).toArray)
869+ val toOuter = new StructType (
870+ (1 to M ).map(i => StructField (s " s $i" , toInner)).toArray)
871+ val inputOuter = Row .fromSeq((1 to M ).map(_ => inputInner))
872+ val outputOuter = Row .fromSeq((1 to M ).map(_ => outputInner))
873+ checkEvaluation(cast(Literal .create(inputOuter, fromOuter), toOuter), outputOuter)
859874 }
860875}
0 commit comments