From e3ae4810090e4ae597a7592af89328424e1c68c1 Mon Sep 17 00:00:00 2001 From: Kousuke Saruta Date: Sun, 20 Dec 2020 16:07:17 +0900 Subject: [PATCH 1/2] Minor change. --- .../org/apache/spark/sql/ExplainSuite.scala | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala index 0ec57c2fcb5ad..4beb9ea3c5b11 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala @@ -233,7 +233,6 @@ class ExplainSuite extends ExplainSuiteHelper with DisableAdaptiveExecutionSuite withSQLConf(SQLConf.DYNAMIC_PARTITION_PRUNING_ENABLED.key -> "true", SQLConf.DYNAMIC_PARTITION_PRUNING_REUSE_BROADCAST_ONLY.key -> "false", SQLConf.EXCHANGE_REUSE_ENABLED.key -> "false") { - withTable("df1", "df2") { spark.range(1000).select(col("id"), col("id").as("k")) .write .partitionBy("k") @@ -273,27 +272,21 @@ class ExplainSuite extends ExplainSuiteHelper with DisableAdaptiveExecutionSuite assert(expected_pattern4.r.findAllMatchIn(normalizedOutput).length == 1) } } - } } } test("SPARK-33850: explain formatted - check presence of subquery in case of AQE") { - withTable("df1") { - withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true") { - withTable("df1") { - spark.range(1, 100) - .write - .format("parquet") - .mode("overwrite") - .saveAsTable("df1") + withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true") { + withTable("df") { + val df = spark.range(1, 100) + df.createTempView("df") - val sqlText = "EXPLAIN FORMATTED SELECT (SELECT min(id) FROM df1) as v" - val expected_pattern1 = - "Subquery:1 Hosting operator id = 2 Hosting Expression = Subquery subquery#x" + val sqlText = "EXPLAIN FORMATTED SELECT (SELECT min(id) FROM df) as v" + val expected_pattern = + "Subquery:1 Hosting operator id = 2 Hosting Expression = Subquery subquery#x" - withNormalizedExplain(sqlText) { normalizedOutput => - assert(expected_pattern1.r.findAllMatchIn(normalizedOutput).length == 1) - } + withNormalizedExplain(sqlText) { normalizedOutput => + assert(expected_pattern.r.findAllMatchIn(normalizedOutput).length == 1) } } } From 658cc9287d1a4a58a8c10a45cc86dd07eef1d9ad Mon Sep 17 00:00:00 2001 From: Kousuke Saruta Date: Mon, 21 Dec 2020 03:01:03 +0900 Subject: [PATCH 2/2] withTable -> withTempView --- sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala index 4beb9ea3c5b11..8b7459fddb59a 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/ExplainSuite.scala @@ -277,7 +277,7 @@ class ExplainSuite extends ExplainSuiteHelper with DisableAdaptiveExecutionSuite test("SPARK-33850: explain formatted - check presence of subquery in case of AQE") { withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true") { - withTable("df") { + withTempView("df") { val df = spark.range(1, 100) df.createTempView("df")