-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22570][SQL] Avoid to create a lot of global variables by using a local variable with allocation of an object in generated code #19797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
41a591a
de5cd38
1046e1d
13e05b7
072cdd2
d4e4b07
36a330d
3b8459d
420b10d
cd4c696
a455ac3
747e215
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import java.util.{Calendar, Locale, TimeZone} | |
| import org.apache.spark.SparkFunSuite | ||
| import org.apache.spark.sql.Row | ||
| import org.apache.spark.sql.catalyst.InternalRow | ||
| import org.apache.spark.sql.catalyst.expressions.codegen.CodegenContext | ||
| import org.apache.spark.sql.catalyst.util.DateTimeTestUtils._ | ||
| import org.apache.spark.sql.catalyst.util.DateTimeUtils | ||
| import org.apache.spark.sql.catalyst.util.DateTimeUtils.TimeZoneGMT | ||
|
|
@@ -846,23 +847,10 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper { | |
| 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) | ||
| test("SPARK-22570: Cast should not create a lot of instance variables") { | ||
| val ctx = new CodegenContext | ||
| cast("1", IntegerType).genCode(ctx).code | ||
| cast("2", LongType).genCode(ctx).code | ||
|
||
| assert(ctx.mutableStates.length == 0) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,9 +165,9 @@ class ComplexTypesSuite extends PlanTest{ | |
| comparePlans(Optimizer execute query, expected) | ||
| } | ||
|
|
||
| test("SPARK-22570: should not create a lot of instance variables") { | ||
| test("SPARK-22570: CreateArray should not create a lot of global variables") { | ||
| val ctx = new CodegenContext | ||
|
||
| (1 to 60000).map(i => CreateArray(Seq(Literal(s"$i"))).genCode(ctx).code) | ||
| CreateArray(Seq(Literal(1))).genCode(ctx).code | ||
|
||
| assert(ctx.mutableStates.length == 0) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: instance variables -> global variables. To match with other two added tests.