Skip to content

Commit

Permalink
[SPARK-34682][SQL] Use PrivateMethodTester instead of reflection
Browse files Browse the repository at this point in the history
### Why are the changes needed?
SPARK-34682 was merged prematurely. This PR implements feedback from the review. I wasn't sure whether I should create a new JIRA or not.

### Does this PR introduce _any_ user-facing change?
No. Just improves the test.

### How was this patch tested?
Updated test.

Closes apache#31798 from andygrove/SPARK-34682-follow-up.

Authored-by: Andy Grove <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
  • Loading branch information
andygrove authored and dongjoon-hyun committed Mar 10, 2021
1 parent fd48438 commit fc182f7
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
package org.apache.spark.sql.execution.adaptive

import java.io.File
import java.lang.reflect.InvocationTargetException
import java.net.URI

import org.apache.log4j.Level
import org.scalatest.PrivateMethodTester

import org.apache.spark.scheduler.{SparkListener, SparkListenerEvent, SparkListenerJobStart}
import org.apache.spark.sql.{Dataset, QueryTest, Row, SparkSession, Strategy}
Expand All @@ -46,7 +46,8 @@ import org.apache.spark.util.Utils
class AdaptiveQueryExecSuite
extends QueryTest
with SharedSparkSession
with AdaptiveSparkPlanHelper {
with AdaptiveSparkPlanHelper
with PrivateMethodTester {

import testImplicits._

Expand Down Expand Up @@ -881,12 +882,11 @@ class AdaptiveQueryExecSuite
val reader = readers.head
val c = reader.canonicalized.asInstanceOf[CustomShuffleReaderExec]
// we can't just call execute() because that has separate checks for canonicalized plans
val doExecute = c.getClass.getMethod("doExecute")
doExecute.setAccessible(true)
val ex = intercept[InvocationTargetException] {
doExecute.invoke(c)
val ex = intercept[IllegalStateException] {
val doExecute = PrivateMethod[Unit](Symbol("doExecute"))
c.invokePrivate(doExecute())
}
assert(ex.getCause.getMessage === "operating on canonicalized plan")
assert(ex.getMessage === "operating on canonicalized plan")
}
}

Expand Down

0 comments on commit fc182f7

Please sign in to comment.