Skip to content

Commit 4585a04

Browse files
address comments
1 parent 2613c30 commit 4585a04

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,8 +1224,7 @@ object SQLConf {
12241224
.booleanConf
12251225
.createWithDefault(true)
12261226

1227-
val REMOVE_REDUNDANT_PROJECTS_ENABLED =
1228-
buildConf("spark.sql.execution.removeRedundantProjects")
1227+
val REMOVE_REDUNDANT_PROJECTS_ENABLED = buildConf("spark.sql.execution.removeRedundantProjects")
12291228
.internal()
12301229
.doc("Whether to remove redundant project exec node based on children's output and " +
12311230
"ordering requirement.")

sql/core/src/test/scala/org/apache/spark/sql/execution/RemoveRedundantProjectsSuite.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@
1717

1818
package org.apache.spark.sql.execution
1919

20-
import org.apache.spark.sql.{DataFrame, QueryTest}
20+
import org.apache.spark.sql.{DataFrame, QueryTest, Row}
2121
import org.apache.spark.sql.internal.SQLConf
2222
import org.apache.spark.sql.test.{SharedSparkSession, SQLTestUtils}
23+
import org.apache.spark.sql.types.StructType
2324
import org.apache.spark.util.Utils
2425

2526
class RemoveRedundantProjectsSuite extends QueryTest with SharedSparkSession with SQLTestUtils {
27+
import testImplicits._
2628

27-
private def assertProjectExecCount(df: DataFrame, expected: Integer): Unit = {
29+
private def assertProjectExecCount(df: DataFrame, expected: Int): Unit = {
2830
withClue(df.queryExecution) {
2931
val plan = df.queryExecution.executedPlan
3032
val actual = plan.collectWithSubqueries { case p: ProjectExec => p }.size
3133
assert(actual == expected)
3234
}
3335
}
3436

35-
private def assertProjectExec(query: String, enabled: Integer, disabled: Integer): Unit = {
37+
private def assertProjectExec(query: String, enabled: Int, disabled: Int): Unit = {
3638
val df = sql(query)
3739
assertProjectExecCount(df, enabled)
3840
val result = df.collect()
@@ -120,9 +122,13 @@ class RemoveRedundantProjectsSuite extends QueryTest with SharedSparkSession wit
120122
}
121123

122124
test("subquery") {
123-
testData
124-
val query = "select key, value from testData where key in " +
125-
"(select sum(a) from testView where a > 5 group by key)"
126-
assertProjectExec(query, 0, 1)
125+
withTempView("testData") {
126+
val data = spark.sparkContext.parallelize((1 to 100).map(i => Row(i, i.toString)))
127+
val schema = new StructType().add("key", "int").add("value", "string")
128+
spark.createDataFrame(data, schema).createOrReplaceTempView("testData")
129+
val query = "select key, value from testData where key in " +
130+
"(select sum(a) from testView where a > 5 group by key)"
131+
assertProjectExec(query, 0, 1)
132+
}
127133
}
128134
}

0 commit comments

Comments
 (0)