Skip to content

Commit eda9201

Browse files
committed
update
1 parent 80ffbf1 commit eda9201

File tree

4 files changed

+104
-1
lines changed

4 files changed

+104
-1
lines changed

gluten-ut/spark32/src/test/scala/org/apache/spark/sql/GlutenDataFrameSuite.scala

+26
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import org.apache.spark.sql.internal.SQLConf
2828
import org.apache.spark.sql.test.SQLTestData.TestData2
2929
import org.apache.spark.sql.types.StringType
3030

31+
import java.io.ByteArrayOutputStream
3132
import java.nio.charset.StandardCharsets
3233

3334
import scala.util.Random
@@ -359,6 +360,31 @@ class GlutenDataFrameSuite extends DataFrameSuite with GlutenSQLTestsTrait {
359360
checkResult(df, expectedBinaryResult)
360361
}
361362

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(
378+
"""== Parsed Logical Plan ==
379+
|'Project [*]
380+
|+- 'UnresolvedRelation [tmp]""".stripMargin))
381+
assert(output.contains(
382+
"""== Physical Plan ==
383+
|*(1) ColumnarToRow
384+
|+- ColumnarRange 0, 10, 1, 2, 10, [id#0L]""".stripMargin))
385+
}
386+
}
387+
362388
private def withExpr(newExpr: Expression): Column = new Column(newExpr)
363389

364390
def equalizer(expr: Expression, other: Any): Column = withExpr {

gluten-ut/spark33/src/test/scala/org/apache/spark/sql/GlutenDataFrameSuite.scala

+26-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.apache.spark.sql
1818

1919
import org.apache.gluten.execution.{ProjectExecTransformer, WholeStageTransformer}
20-
2120
import org.apache.spark.SparkException
2221
import org.apache.spark.sql.catalyst.expressions.{EqualTo, Expression}
2322
import org.apache.spark.sql.execution.ColumnarShuffleExchangeExec
@@ -28,6 +27,7 @@ import org.apache.spark.sql.internal.SQLConf
2827
import org.apache.spark.sql.test.SQLTestData.TestData2
2928
import org.apache.spark.sql.types.StringType
3029

30+
import java.io.ByteArrayOutputStream
3131
import java.nio.charset.StandardCharsets
3232

3333
import scala.util.Random
@@ -360,6 +360,31 @@ class GlutenDataFrameSuite extends DataFrameSuite with GlutenSQLTestsTrait {
360360
checkResult(df, expectedBinaryResult)
361361
}
362362

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(
378+
"""== Parsed Logical Plan ==
379+
|'Project [*]
380+
|+- 'UnresolvedRelation [tmp]""".stripMargin))
381+
assert(output.contains(
382+
"""== Physical Plan ==
383+
|*(1) ColumnarToRow
384+
|+- ColumnarRange 0, 10, 1, 2, 10, [id#0L]""".stripMargin))
385+
}
386+
}
387+
363388
private def withExpr(newExpr: Expression): Column = new Column(newExpr)
364389

365390
def equalizer(expr: Expression, other: Any): Column = withExpr {

gluten-ut/spark34/src/test/scala/org/apache/spark/sql/GlutenDataFrameSuite.scala

+26
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import org.apache.spark.sql.internal.SQLConf
2828
import org.apache.spark.sql.test.SQLTestData.TestData2
2929
import org.apache.spark.sql.types.StringType
3030

31+
import java.io.ByteArrayOutputStream
3132
import java.nio.charset.StandardCharsets
3233

3334
import scala.util.Random
@@ -360,6 +361,31 @@ class GlutenDataFrameSuite extends DataFrameSuite with GlutenSQLTestsTrait {
360361
checkResult(df, expectedBinaryResult)
361362
}
362363

364+
test("SPARK-27439: Explain result should match collected result after view change - re-write") {
365+
withTempView("test", "test2", "tmp") {
366+
spark.range(10).createOrReplaceTempView("test")
367+
spark.range(5).createOrReplaceTempView("test2")
368+
spark.sql("select * from test").createOrReplaceTempView("tmp")
369+
val df = spark.sql("select * from tmp")
370+
spark.sql("select * from test2").createOrReplaceTempView("tmp")
371+
372+
val captured = new ByteArrayOutputStream()
373+
Console.withOut(captured) {
374+
df.explain(extended = true)
375+
}
376+
checkAnswer(df, spark.range(10).toDF)
377+
val output = captured.toString
378+
assert(output.contains(
379+
"""== Parsed Logical Plan ==
380+
|'Project [*]
381+
|+- 'UnresolvedRelation [tmp]""".stripMargin))
382+
assert(output.contains(
383+
"""== Physical Plan ==
384+
|*(1) ColumnarToRow
385+
|+- ColumnarRange 0, 10, 1, 2, 10, [id#0L]""".stripMargin))
386+
}
387+
}
388+
363389
private def withExpr(newExpr: Expression): Column = new Column(newExpr)
364390

365391
def equalizer(expr: Expression, other: Any): Column = withExpr {

gluten-ut/spark35/src/test/scala/org/apache/spark/sql/GlutenDataFrameSuite.scala

+26
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import org.apache.spark.sql.internal.SQLConf
2929
import org.apache.spark.sql.test.SQLTestData.TestData2
3030
import org.apache.spark.sql.types.StringType
3131

32+
import java.io.ByteArrayOutputStream
3233
import java.nio.charset.StandardCharsets
3334

3435
import scala.util.Random
@@ -372,6 +373,31 @@ class GlutenDataFrameSuite extends DataFrameSuite with GlutenSQLTestsTrait {
372373
}
373374
}
374375

376+
test("SPARK-27439: Explain result should match collected result after view change - re-write") {
377+
withTempView("test", "test2", "tmp") {
378+
spark.range(10).createOrReplaceTempView("test")
379+
spark.range(5).createOrReplaceTempView("test2")
380+
spark.sql("select * from test").createOrReplaceTempView("tmp")
381+
val df = spark.sql("select * from tmp")
382+
spark.sql("select * from test2").createOrReplaceTempView("tmp")
383+
384+
val captured = new ByteArrayOutputStream()
385+
Console.withOut(captured) {
386+
df.explain(extended = true)
387+
}
388+
checkAnswer(df, spark.range(10).toDF)
389+
val output = captured.toString
390+
assert(output.contains(
391+
"""== Parsed Logical Plan ==
392+
|'Project [*]
393+
|+- 'UnresolvedRelation [tmp]""".stripMargin))
394+
assert(output.contains(
395+
"""== Physical Plan ==
396+
|*(1) ColumnarToRow
397+
|+- ColumnarRange 0, 10, 1, 2, 10, [id#0L]""".stripMargin))
398+
}
399+
}
400+
375401
private def withExpr(newExpr: Expression): Column = new Column(newExpr)
376402

377403
def equalizer(expr: Expression, other: Any): Column = withExpr {

0 commit comments

Comments
 (0)