Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19797#discussion_r153973840
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala
---
@@ -845,4 +845,24 @@ class CastSuite extends SparkFunSuite with
ExpressionEvalHelper {
val outputOuter = Row.fromSeq((1 to N).map(_ => outputInner))
checkEvaluation(cast(Literal.create(inputOuter, fromOuter), toOuter),
outputOuter)
}
+
+ test("SPARK-22570: should not create a lot of instance variables") {
+ val N = 30000
+
+ val from1 = new StructType(
+ (1 to N).map(i => StructField(s"s$i", StringType)).toArray)
+ val to1 = new StructType(
+ (1 to N).map(i => StructField(s"i$i", IntegerType)).toArray)
+ val input1 = Row.fromSeq((1 to N).map(i => i.toString))
+ val output1 = Row.fromSeq((1 to N))
+ checkEvaluation(cast(Literal.create(input1, from1), to1), output1)
+
+ val from2 = new StructType(
+ (1 to N).map(i => StructField(s"s$i", StringType)).toArray)
+ val to2 = new StructType(
+ (1 to N).map(i => StructField(s"i$i", LongType)).toArray)
+ val input2 = Row.fromSeq((1 to N).map(i => i.toString))
+ val output2 = Row.fromSeq((1 to N).map(i => i.toLong))
+ checkEvaluation(cast(Literal.create(input2, from2), to2), output2)
--- End diff --
can we also simplify this test like the other 2?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]