Skip to content

Commit 3c8be39

Browse files
sarutakmaropu
authored andcommitted
[SPARK-33850][SQL][FOLLOWUP] Improve and cleanup the test code
### What changes were proposed in this pull request? This PR mainly improves and cleans up the test code introduced in #30855 based on the comment. The test code is actually taken from another test `explain formatted - check presence of subquery in case of DPP` so this PR cleans the code too ( removed unnecessary `withTable`). ### Why are the changes needed? To keep the test code clean. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? `ExplainSuite` passes. Closes #30861 from sarutak/followup-SPARK-33850. Authored-by: Kousuke Saruta <[email protected]> Signed-off-by: Takeshi Yamamuro <[email protected]>
1 parent 1339168 commit 3c8be39

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ class ExplainSuite extends ExplainSuiteHelper with DisableAdaptiveExecutionSuite
233233
withSQLConf(SQLConf.DYNAMIC_PARTITION_PRUNING_ENABLED.key -> "true",
234234
SQLConf.DYNAMIC_PARTITION_PRUNING_REUSE_BROADCAST_ONLY.key -> "false",
235235
SQLConf.EXCHANGE_REUSE_ENABLED.key -> "false") {
236-
withTable("df1", "df2") {
237236
spark.range(1000).select(col("id"), col("id").as("k"))
238237
.write
239238
.partitionBy("k")
@@ -273,27 +272,21 @@ class ExplainSuite extends ExplainSuiteHelper with DisableAdaptiveExecutionSuite
273272
assert(expected_pattern4.r.findAllMatchIn(normalizedOutput).length == 1)
274273
}
275274
}
276-
}
277275
}
278276
}
279277

280278
test("SPARK-33850: explain formatted - check presence of subquery in case of AQE") {
281-
withTable("df1") {
282-
withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true") {
283-
withTable("df1") {
284-
spark.range(1, 100)
285-
.write
286-
.format("parquet")
287-
.mode("overwrite")
288-
.saveAsTable("df1")
279+
withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true") {
280+
withTempView("df") {
281+
val df = spark.range(1, 100)
282+
df.createTempView("df")
289283

290-
val sqlText = "EXPLAIN FORMATTED SELECT (SELECT min(id) FROM df1) as v"
291-
val expected_pattern1 =
292-
"Subquery:1 Hosting operator id = 2 Hosting Expression = Subquery subquery#x"
284+
val sqlText = "EXPLAIN FORMATTED SELECT (SELECT min(id) FROM df) as v"
285+
val expected_pattern =
286+
"Subquery:1 Hosting operator id = 2 Hosting Expression = Subquery subquery#x"
293287

294-
withNormalizedExplain(sqlText) { normalizedOutput =>
295-
assert(expected_pattern1.r.findAllMatchIn(normalizedOutput).length == 1)
296-
}
288+
withNormalizedExplain(sqlText) { normalizedOutput =>
289+
assert(expected_pattern.r.findAllMatchIn(normalizedOutput).length == 1)
297290
}
298291
}
299292
}

0 commit comments

Comments
 (0)