Skip to content

Commit

Permalink
[SPARK-51292][SQL] Remove unnecessary inheritance from PlanTestBase, …
Browse files Browse the repository at this point in the history
…ExpressionEvalHelper and PlanTest

### What changes were proposed in this pull request?
This PR proposes to remove unnecessary inheritance from `PlanTestBase`, `ExpressionEvalHelper` and `PlanTest`.

### Why are the changes needed?

1. Some class extends both `ExpressionEvalHelper` and `PlanTestBase`, but `ExpressionEvalHelper` already extends `PlanTestBase`.
```
trait ExpressionEvalHelper extends ScalaCheckDrivenPropertyChecks with PlanTestBase {
  self: SparkFunSuite =>
  ...
}
```
2. Class `NullDownPropagationSuite`, `OptimizeCsvExprsSuite`, `PushFoldableIntoBranchesSuite` doesn't need `ExpressionEvalHelper` at all.
3. Some class extends both `QueryTest` and `PlanTest`, but `QueryTest` already extends `PlanTest`.
```
abstract class QueryTest extends PlanTest {
...
}
```

### Does this PR introduce _any_ user-facing change?
'No'.
Just update the inner code.

### How was this patch tested?
GA.

### Was this patch authored or co-authored using generative AI tooling?
'No'.

Closes #50047 from beliefer/SPARK-51292.

Authored-by: beliefer <beliefer@163.com>
Signed-off-by: beliefer <beliefer@163.com>
(cherry picked from commit 3027968)
Signed-off-by: beliefer <beliefer@163.com>
  • Loading branch information
beliefer committed Feb 23, 2025
1 parent cb2a9da commit b2e0e76
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ import org.scalatest.exceptions.TestFailedException
import org.apache.spark.SparkFunSuite
import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.plans.PlanTestBase
import org.apache.spark.sql.catalyst.util._
import org.apache.spark.sql.catalyst.util.DateTimeTestUtils.{PST, UTC_OPT}
import org.apache.spark.sql.types._
import org.apache.spark.unsafe.types.{CalendarInterval, UTF8String}

class CsvExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper with PlanTestBase {
class CsvExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
val badCsv = "\u0000\u0000\u0000A\u0001AAA"

test("from_csv") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.DataTypeMismatch
import org.apache.spark.sql.catalyst.expressions.Cast._
import org.apache.spark.sql.catalyst.expressions.codegen.GenerateUnsafeProjection
import org.apache.spark.sql.catalyst.plans.PlanTestBase
import org.apache.spark.sql.catalyst.util._
import org.apache.spark.sql.catalyst.util.DateTimeTestUtils.{PST, UTC, UTC_OPT}
import org.apache.spark.sql.types._
import org.apache.spark.unsafe.types.{CalendarInterval, UTF8String}

class JsonExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper with PlanTestBase {
class JsonExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
val json =
"""
|{"store":{"fruit":[{"weight":8,"type":"apple"},{"weight":9,"type":"pear"}],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ import org.scalatest.matchers.should.Matchers._

import org.apache.spark.SparkFunSuite
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.plans.PlanTestBase
import org.apache.spark.sql.catalyst.util._
import org.apache.spark.sql.types.{IntegerType, LongType, _}
import org.apache.spark.unsafe.array.ByteArrayMethods
import org.apache.spark.unsafe.types.{CalendarInterval, UTF8String}
import org.apache.spark.util.ArrayImplicits._

class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with PlanTestBase
with ExpressionEvalHelper {
class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with ExpressionEvalHelper {

private def roundedSize(size: Int) = ByteArrayMethods.roundNumberOfBytesToNearestWord(size)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ import org.apache.spark.{SparkException, SparkFunSuite}
import org.apache.spark.sql.{AnalysisException, Row}
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.codegen.GenerateUnsafeProjection
import org.apache.spark.sql.catalyst.plans.PlanTestBase
import org.apache.spark.sql.catalyst.util._
import org.apache.spark.sql.catalyst.util.DateTimeTestUtils.{PST, UTC, UTC_OPT}
import org.apache.spark.sql.types._
import org.apache.spark.unsafe.types.UTF8String

class XmlExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper with PlanTestBase {
class XmlExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
test("from_xml escaping") {
val schema = StructType(StructField("\"quote", IntegerType) :: Nil)
GenerateUnsafeProjection.generate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.apache.spark.sql.catalyst.plans.PlanTest
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.rules._

class NullDownPropagationSuite extends PlanTest with ExpressionEvalHelper {
class NullDownPropagationSuite extends PlanTest {

object Optimize extends RuleExecutor[LogicalPlan] {
val batches =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.apache.spark.sql.catalyst.rules.RuleExecutor
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types._

class OptimizeCsvExprsSuite extends PlanTest with ExpressionEvalHelper {
class OptimizeCsvExprsSuite extends PlanTest {

private var csvExpressionOptimizeEnabled: Boolean = _
protected override def beforeAll(): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.apache.spark.sql.types.{BooleanType, IntegerType, StringType, Timesta
import org.apache.spark.unsafe.types.CalendarInterval


class PushFoldableIntoBranchesSuite extends PlanTest with ExpressionEvalHelper {
class PushFoldableIntoBranchesSuite extends PlanTest {

object Optimize extends RuleExecutor[LogicalPlan] {
val batches = Batch("PushFoldableIntoBranches", FixedPoint(50),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ import java.time.{Instant, LocalDate, LocalDateTime, ZoneId}

import org.apache.spark.sql.catalyst.expressions.Literal
import org.apache.spark.sql.catalyst.parser.ParseException
import org.apache.spark.sql.catalyst.plans.PlanTest
import org.apache.spark.sql.catalyst.plans.logical.Limit
import org.apache.spark.sql.functions.{array, call_function, lit, map, map_from_arrays, map_from_entries, str_to_map, struct}
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SharedSparkSession

class ParametersSuite extends QueryTest with SharedSparkSession with PlanTest {
class ParametersSuite extends QueryTest with SharedSparkSession {

test("bind named parameters") {
val sqlText =
Expand Down

0 comments on commit b2e0e76

Please sign in to comment.