@@ -28,6 +28,7 @@ import org.apache.spark.sql.internal.SQLConf
28
28
import org .apache .spark .sql .test .SQLTestData .TestData2
29
29
import org .apache .spark .sql .types .StringType
30
30
31
+ import java .io .ByteArrayOutputStream
31
32
import java .nio .charset .StandardCharsets
32
33
33
34
import scala .util .Random
@@ -359,6 +360,29 @@ class GlutenDataFrameSuite extends DataFrameSuite with GlutenSQLTestsTrait {
359
360
checkResult(df, expectedBinaryResult)
360
361
}
361
362
363
+ test(" SPARK-27439: Explain result should match collected result after view change - re-write" ) {
364
+ withTempView(" test" , " test2" , " tmp" ) {
365
+ spark.range(10 ).createOrReplaceTempView(" test" )
366
+ spark.range(5 ).createOrReplaceTempView(" test2" )
367
+ spark.sql(" select * from test" ).createOrReplaceTempView(" tmp" )
368
+ val df = spark.sql(" select * from tmp" )
369
+ spark.sql(" select * from test2" ).createOrReplaceTempView(" tmp" )
370
+
371
+ val captured = new ByteArrayOutputStream ()
372
+ Console .withOut(captured) {
373
+ df.explain(extended = true )
374
+ }
375
+ checkAnswer(df, spark.range(10 ).toDF)
376
+ val output = captured.toString
377
+ assert(output.contains(""" == Parsed Logical Plan ==
378
+ |'Project [*]
379
+ |+- 'UnresolvedRelation [tmp]""" .stripMargin))
380
+ assert(output.contains(""" == Physical Plan ==
381
+ |*(1) ColumnarToRow
382
+ |+- ColumnarRange 0, 10, 1, 2, 10, [id#0L]""" .stripMargin))
383
+ }
384
+ }
385
+
362
386
private def withExpr (newExpr : Expression ): Column = new Column (newExpr)
363
387
364
388
def equalizer (expr : Expression , other : Any ): Column = withExpr {
0 commit comments