Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GLUTEN-8633] [VL] Rewrite tests for Gluten ColumnarRange #8634

Merged
merged 5 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ class ClickHouseTestSettings extends BackendTestSettings {
.exclude("SPARK-24165: CaseWhen/If - nullability of nested types")
.exclude("SPARK-27671: Fix analysis exception when casting null in nested field in struct")
.exclude("summary")
.excludeGlutenTest(
"SPARK-27439: Explain result should match collected result after view change")
.excludeGlutenTest("distributeBy and localSort")
.excludeGlutenTest("describe")
.excludeGlutenTest("Allow leading/trailing whitespace in string before casting")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SQLTestData.TestData2
import org.apache.spark.sql.types.StringType

import java.io.ByteArrayOutputStream
import java.nio.charset.StandardCharsets

import scala.util.Random
Expand Down Expand Up @@ -359,6 +360,29 @@ class GlutenDataFrameSuite extends DataFrameSuite with GlutenSQLTestsTrait {
checkResult(df, expectedBinaryResult)
}

testGluten("SPARK-27439: Explain result should match collected result after view change") {
withTempView("test", "test2", "tmp") {
spark.range(10).createOrReplaceTempView("test")
spark.range(5).createOrReplaceTempView("test2")
spark.sql("select * from test").createOrReplaceTempView("tmp")
val df = spark.sql("select * from tmp")
spark.sql("select * from test2").createOrReplaceTempView("tmp")

val captured = new ByteArrayOutputStream()
Console.withOut(captured) {
df.explain(extended = true)
}
checkAnswer(df, spark.range(10).toDF)
val output = captured.toString
assert(output.contains("""== Parsed Logical Plan ==
|'Project [*]
|+- 'UnresolvedRelation [tmp]""".stripMargin))
assert(output.contains("""== Physical Plan ==
|*(1) ColumnarToRow
|+- ColumnarRange 0, 10, 1, 2, 10""".stripMargin))
}
}

private def withExpr(newExpr: Expression): Column = new Column(newExpr)

def equalizer(expr: Expression, other: Any): Column = withExpr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ class ClickHouseTestSettings extends BackendTestSettings {
.exclude("SPARK-24165: CaseWhen/If - nullability of nested types")
.exclude("SPARK-27671: Fix analysis exception when casting null in nested field in struct")
.exclude("summary")
.excludeGlutenTest(
"SPARK-27439: Explain result should match collected result after view change")
.excludeGlutenTest("distributeBy and localSort")
.excludeGlutenTest("describe")
.excludeGlutenTest("Allow leading/trailing whitespace in string before casting")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SQLTestData.TestData2
import org.apache.spark.sql.types.StringType

import java.io.ByteArrayOutputStream
import java.nio.charset.StandardCharsets

import scala.util.Random
Expand Down Expand Up @@ -360,6 +361,29 @@ class GlutenDataFrameSuite extends DataFrameSuite with GlutenSQLTestsTrait {
checkResult(df, expectedBinaryResult)
}

testGluten("SPARK-27439: Explain result should match collected result after view change") {
withTempView("test", "test2", "tmp") {
spark.range(10).createOrReplaceTempView("test")
spark.range(5).createOrReplaceTempView("test2")
spark.sql("select * from test").createOrReplaceTempView("tmp")
val df = spark.sql("select * from tmp")
spark.sql("select * from test2").createOrReplaceTempView("tmp")

val captured = new ByteArrayOutputStream()
Console.withOut(captured) {
df.explain(extended = true)
}
checkAnswer(df, spark.range(10).toDF)
val output = captured.toString
assert(output.contains("""== Parsed Logical Plan ==
|'Project [*]
|+- 'UnresolvedRelation [tmp]""".stripMargin))
assert(output.contains("""== Physical Plan ==
|*(1) ColumnarToRow
|+- ColumnarRange 0, 10, 1, 2, 10""".stripMargin))
}
}

private def withExpr(newExpr: Expression): Column = new Column(newExpr)

def equalizer(expr: Expression, other: Any): Column = withExpr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ class ClickHouseTestSettings extends BackendTestSettings {
.exclude("SPARK-24165: CaseWhen/If - nullability of nested types")
.exclude("SPARK-27671: Fix analysis exception when casting null in nested field in struct")
.exclude("summary")
.excludeGlutenTest(
"SPARK-27439: Explain result should match collected result after view change")
.excludeGlutenTest("distributeBy and localSort")
.excludeGlutenTest("describe")
.excludeGlutenTest("Allow leading/trailing whitespace in string before casting")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SQLTestData.TestData2
import org.apache.spark.sql.types.StringType

import java.io.ByteArrayOutputStream
import java.nio.charset.StandardCharsets

import scala.util.Random
Expand Down Expand Up @@ -360,6 +361,29 @@ class GlutenDataFrameSuite extends DataFrameSuite with GlutenSQLTestsTrait {
checkResult(df, expectedBinaryResult)
}

testGluten("SPARK-27439: Explain result should match collected result after view change") {
withTempView("test", "test2", "tmp") {
spark.range(10).createOrReplaceTempView("test")
spark.range(5).createOrReplaceTempView("test2")
spark.sql("select * from test").createOrReplaceTempView("tmp")
val df = spark.sql("select * from tmp")
spark.sql("select * from test2").createOrReplaceTempView("tmp")

val captured = new ByteArrayOutputStream()
Console.withOut(captured) {
df.explain(extended = true)
}
checkAnswer(df, spark.range(10).toDF)
val output = captured.toString
assert(output.contains("""== Parsed Logical Plan ==
|'Project [*]
|+- 'UnresolvedRelation [tmp]""".stripMargin))
assert(output.contains("""== Physical Plan ==
|*(1) ColumnarToRow
|+- ColumnarRange 0, 10, 1, 2, 10""".stripMargin))
}
}

private def withExpr(newExpr: Expression): Column = new Column(newExpr)

def equalizer(expr: Expression, other: Any): Column = withExpr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ class ClickHouseTestSettings extends BackendTestSettings {
.excludeCH("SPARK-28067: Aggregate sum should not return wrong results for decimal overflow")
.excludeCH("SPARK-35955: Aggregate avg should not return wrong results for decimal overflow")
.excludeCH("summary")
.excludeGlutenTest(
"SPARK-27439: Explain result should match collected result after view change")
.excludeCH(
"SPARK-8608: call `show` on local DataFrame with random columns should return same value")
.excludeCH(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SQLTestData.TestData2
import org.apache.spark.sql.types.StringType

import java.io.ByteArrayOutputStream
import java.nio.charset.StandardCharsets

import scala.util.Random
Expand Down Expand Up @@ -371,6 +372,29 @@ class GlutenDataFrameSuite extends DataFrameSuite with GlutenSQLTestsTrait {
}
}

testGluten("SPARK-27439: Explain result should match collected result after view change") {
withTempView("test", "test2", "tmp") {
spark.range(10).createOrReplaceTempView("test")
spark.range(5).createOrReplaceTempView("test2")
spark.sql("select * from test").createOrReplaceTempView("tmp")
val df = spark.sql("select * from tmp")
spark.sql("select * from test2").createOrReplaceTempView("tmp")

val captured = new ByteArrayOutputStream()
Console.withOut(captured) {
df.explain(extended = true)
}
checkAnswer(df, spark.range(10).toDF)
val output = captured.toString
assert(output.contains("""== Parsed Logical Plan ==
|'Project [*]
|+- 'UnresolvedRelation [tmp]""".stripMargin))
assert(output.contains("""== Physical Plan ==
|*(1) ColumnarToRow
|+- ColumnarRange 0, 10, 1, 2, 10""".stripMargin))
}
}

private def withExpr(newExpr: Expression): Column = new Column(newExpr)

def equalizer(expr: Expression, other: Any): Column = withExpr {
Expand Down
Loading