AngersZhuuuu commented on a change in pull request #29085:
URL: https://github.com/apache/spark/pull/29085#discussion_r458776096
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveScriptTransformationSuite.scala
##########
@@ -20,78 +20,44 @@ package org.apache.spark.sql.hive.execution
import java.sql.Timestamp
import org.apache.hadoop.hive.serde2.`lazy`.LazySimpleSerDe
-import org.scalatest.Assertions._
-import org.scalatest.BeforeAndAfterEach
import org.scalatest.exceptions.TestFailedException
-import org.apache.spark.{SparkException, TaskContext, TestUtils}
-import org.apache.spark.rdd.RDD
-import org.apache.spark.sql.Column
-import org.apache.spark.sql.catalyst.InternalRow
-import org.apache.spark.sql.catalyst.expressions.{Attribute,
AttributeReference}
-import org.apache.spark.sql.catalyst.plans.physical.Partitioning
-import org.apache.spark.sql.execution.{SparkPlan, SparkPlanTest, UnaryExecNode}
+import org.apache.spark.{SparkException, TestUtils}
+import org.apache.spark.sql.catalyst.expressions.{Attribute,
AttributeReference, Expression}
+import org.apache.spark.sql.execution._
+import org.apache.spark.sql.functions._
import org.apache.spark.sql.hive.HiveUtils
import org.apache.spark.sql.hive.test.TestHiveSingleton
-import org.apache.spark.sql.test.SQLTestUtils
-import org.apache.spark.sql.types.StringType
-
-class HiveScriptTransformationSuite extends SparkPlanTest with SQLTestUtils
with TestHiveSingleton
- with BeforeAndAfterEach {
- import spark.implicits._
-
- private val noSerdeIOSchema = HiveScriptIOSchema(
- inputRowFormat = Seq.empty,
- outputRowFormat = Seq.empty,
- inputSerdeClass = None,
- outputSerdeClass = None,
- inputSerdeProps = Seq.empty,
- outputSerdeProps = Seq.empty,
- recordReaderClass = None,
- recordWriterClass = None,
- schemaLess = false
- )
-
- private val serdeIOSchema = noSerdeIOSchema.copy(
- inputSerdeClass = Some(classOf[LazySimpleSerDe].getCanonicalName),
- outputSerdeClass = Some(classOf[LazySimpleSerDe].getCanonicalName)
- )
-
- private var defaultUncaughtExceptionHandler: Thread.UncaughtExceptionHandler
= _
-
- private val uncaughtExceptionHandler = new TestUncaughtExceptionHandler
-
- protected override def beforeAll(): Unit = {
- super.beforeAll()
- defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler
- Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler)
+import org.apache.spark.sql.types._
+import org.apache.spark.unsafe.types.CalendarInterval
+
+class HiveScriptTransformationSuite extends BaseScriptTransformationSuite with
TestHiveSingleton {
+ import testImplicits._
+
+ import ScriptTransformationIOSchema._
+
+ override def isHive23OrSpark: Boolean = HiveUtils.isHive23
+
+ override def createScriptTransformationExec(
+ input: Seq[Expression],
+ script: String,
+ output: Seq[Attribute],
+ child: SparkPlan,
+ ioschema: ScriptTransformationIOSchema): BaseScriptTransformationExec = {
+ HiveScriptTransformationExec(
+ input = input,
+ script = script,
+ output = output,
+ child = child,
+ ioschema = ioschema
+ )
}
- protected override def afterAll(): Unit = {
- super.afterAll()
- Thread.setDefaultUncaughtExceptionHandler(defaultUncaughtExceptionHandler)
- }
-
- override protected def afterEach(): Unit = {
- super.afterEach()
- uncaughtExceptionHandler.cleanStatus()
- }
-
- test("cat without SerDe") {
- assume(TestUtils.testCommandAvailable("/bin/bash"))
-
- val rowsDf = Seq("a", "b", "c").map(Tuple1.apply).toDF("a")
- checkAnswer(
- rowsDf,
- (child: SparkPlan) => new HiveScriptTransformationExec(
- input = Seq(rowsDf.col("a").expr),
- script = "cat",
- output = Seq(AttributeReference("a", StringType)()),
- child = child,
- ioschema = noSerdeIOSchema
- ),
- rowsDf.collect())
- assert(uncaughtExceptionHandler.exception.isEmpty)
+ private val serdeIOSchema: ScriptTransformationIOSchema = {
Review comment:
DOne
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]