This is an automated email from the ASF dual-hosted git repository.
rui-mo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git
The following commit(s) were added to refs/heads/main by this push:
new c1106d082c [GLUTEN-13633][CORE] Fix flaky SPARK-25158 Hive script
tests (#13634)
c1106d082c is described below
commit c1106d082c932c2b0bb04ec9b229fc6704b8debb
Author: Wechar Yu <[email protected]>
AuthorDate: Tue Dec 1 02:34:20 2026 +0800
[GLUTEN-13633][CORE] Fix flaky SPARK-25158 Hive script tests (#13634)
---
.../sql/hive/execution/GlutenSQLQuerySuite.scala | 48 ++++++++++++++++++++--
.../sql/hive/execution/GlutenSQLQuerySuite.scala | 48 ++++++++++++++++++++--
.../sql/hive/execution/GlutenSQLQuerySuite.scala | 48 ++++++++++++++++++++--
.../sql/hive/execution/GlutenSQLQuerySuite.scala | 48 ++++++++++++++++++++--
.../sql/hive/execution/GlutenSQLQuerySuite.scala | 48 ++++++++++++++++++++--
5 files changed, 220 insertions(+), 20 deletions(-)
diff --git
a/gluten-ut/spark34/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
b/gluten-ut/spark34/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
index 6a6fa67a6d..2d5d94b19d 100644
---
a/gluten-ut/spark34/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
+++
b/gluten-ut/spark34/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
@@ -16,9 +16,10 @@
*/
package org.apache.spark.sql.hive.execution
-import org.apache.spark.TestUtils
+import org.apache.spark.{SparkException, TestUtils}
import org.apache.spark.sql.{GlutenTestSetWithSystemPropertyTrait, Row}
import
org.apache.spark.sql.connector.catalog.CatalogManager.SESSION_CATALOG_NAME
+import org.apache.spark.sql.execution.TestUncaughtExceptionHandler
import org.apache.spark.tags.SlowHiveTest
import java.sql.Date
@@ -29,12 +30,14 @@ trait GlutenSQLQuerySuiteBase
with GlutenHiveResourcePathSupport {
override def testNameBlackList: Seq[String] = Seq(
- // Rewritten with workspace-backed jar paths because TestHive.getHiveFile
resolves
- // these jars from the Spark test jars in gluten-ut.
+ // Rewritten with workspace-backed resource paths because the upstream
tests resolve
+ // resources from Spark test jars in gluten-ut.
"script",
"describe functions - user defined functions",
"describe functions - temporary user defined functions",
- "SPARK-32668: HiveGenericUDTF initialize UDTF should use
StructObjectInspector method"
+ "SPARK-32668: HiveGenericUDTF initialize UDTF should use
StructObjectInspector method",
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception"
)
override def beforeAll(): Unit = {
@@ -42,6 +45,43 @@ trait GlutenSQLQuerySuiteBase
GlutenTestHiveTables.registerHiveQTestUtilsTables(hiveTestResourceDir)
}
+ testGluten(
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception") {
+ assume(TestUtils.testCommandAvailable("python3"))
+ withTempView("test") {
+ import spark.implicits._
+
+ val defaultUncaughtExceptionHandler =
Thread.getDefaultUncaughtExceptionHandler
+ try {
+ val uncaughtExceptionHandler = new TestUncaughtExceptionHandler
+ Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler)
+
+ // Use a bad udf to generate failed inputs.
+ val badUDF = org.apache.spark.sql.functions.udf(
+ (x: Int) => {
+ if (x < 1) x
+ else throw new RuntimeException("Failed to produce data.")
+ })
+ spark
+ .range(5)
+ .select(badUDF($"id").as("a"))
+ .createOrReplaceTempView("test")
+ val scriptFilePath = hiveResourcePath("data").toFile.getCanonicalPath
+ val e = intercept[SparkException] {
+ sql(
+ s"""FROM test SELECT TRANSFORM(a)
+ |USING 'python3 $scriptFilePath/scripts/test_transform.py "\t"'
+ """.stripMargin).collect()
+ }
+ assert(e.getMessage.contains("Failed to produce data."))
+ assert(uncaughtExceptionHandler.exception.isEmpty)
+ } finally {
+
Thread.setDefaultUncaughtExceptionHandler(defaultUncaughtExceptionHandler)
+ }
+ }
+ }
+
testGluten("script") {
withTempView("script_table") {
import spark.implicits._
diff --git
a/gluten-ut/spark35/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
b/gluten-ut/spark35/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
index 6a6fa67a6d..2d5d94b19d 100644
---
a/gluten-ut/spark35/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
+++
b/gluten-ut/spark35/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
@@ -16,9 +16,10 @@
*/
package org.apache.spark.sql.hive.execution
-import org.apache.spark.TestUtils
+import org.apache.spark.{SparkException, TestUtils}
import org.apache.spark.sql.{GlutenTestSetWithSystemPropertyTrait, Row}
import
org.apache.spark.sql.connector.catalog.CatalogManager.SESSION_CATALOG_NAME
+import org.apache.spark.sql.execution.TestUncaughtExceptionHandler
import org.apache.spark.tags.SlowHiveTest
import java.sql.Date
@@ -29,12 +30,14 @@ trait GlutenSQLQuerySuiteBase
with GlutenHiveResourcePathSupport {
override def testNameBlackList: Seq[String] = Seq(
- // Rewritten with workspace-backed jar paths because TestHive.getHiveFile
resolves
- // these jars from the Spark test jars in gluten-ut.
+ // Rewritten with workspace-backed resource paths because the upstream
tests resolve
+ // resources from Spark test jars in gluten-ut.
"script",
"describe functions - user defined functions",
"describe functions - temporary user defined functions",
- "SPARK-32668: HiveGenericUDTF initialize UDTF should use
StructObjectInspector method"
+ "SPARK-32668: HiveGenericUDTF initialize UDTF should use
StructObjectInspector method",
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception"
)
override def beforeAll(): Unit = {
@@ -42,6 +45,43 @@ trait GlutenSQLQuerySuiteBase
GlutenTestHiveTables.registerHiveQTestUtilsTables(hiveTestResourceDir)
}
+ testGluten(
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception") {
+ assume(TestUtils.testCommandAvailable("python3"))
+ withTempView("test") {
+ import spark.implicits._
+
+ val defaultUncaughtExceptionHandler =
Thread.getDefaultUncaughtExceptionHandler
+ try {
+ val uncaughtExceptionHandler = new TestUncaughtExceptionHandler
+ Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler)
+
+ // Use a bad udf to generate failed inputs.
+ val badUDF = org.apache.spark.sql.functions.udf(
+ (x: Int) => {
+ if (x < 1) x
+ else throw new RuntimeException("Failed to produce data.")
+ })
+ spark
+ .range(5)
+ .select(badUDF($"id").as("a"))
+ .createOrReplaceTempView("test")
+ val scriptFilePath = hiveResourcePath("data").toFile.getCanonicalPath
+ val e = intercept[SparkException] {
+ sql(
+ s"""FROM test SELECT TRANSFORM(a)
+ |USING 'python3 $scriptFilePath/scripts/test_transform.py "\t"'
+ """.stripMargin).collect()
+ }
+ assert(e.getMessage.contains("Failed to produce data."))
+ assert(uncaughtExceptionHandler.exception.isEmpty)
+ } finally {
+
Thread.setDefaultUncaughtExceptionHandler(defaultUncaughtExceptionHandler)
+ }
+ }
+ }
+
testGluten("script") {
withTempView("script_table") {
import spark.implicits._
diff --git
a/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
b/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
index 9af7bfca46..2571b567d2 100644
---
a/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
+++
b/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
@@ -16,8 +16,9 @@
*/
package org.apache.spark.sql.hive.execution
-import org.apache.spark.TestUtils
+import org.apache.spark.{SparkException, TestUtils}
import org.apache.spark.sql.{GlutenTestSetWithSystemPropertyTrait, Row}
+import org.apache.spark.sql.execution.TestUncaughtExceptionHandler
import org.apache.spark.tags.SlowHiveTest
trait GlutenSQLQuerySuiteBase
@@ -26,9 +27,11 @@ trait GlutenSQLQuerySuiteBase
with GlutenHiveResourcePathSupport {
override def testNameBlackList: Seq[String] = Seq(
- // Rewritten with a workspace-backed script path because
getTestResourcePath resolves
- // test-script.sh from the spark-hive tests jar in gluten-ut.
- "script"
+ // Rewritten with workspace-backed resource paths because the upstream
tests resolve
+ // resources from Spark test jars in gluten-ut.
+ "script",
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception"
)
override def beforeAll(): Unit = {
@@ -36,6 +39,43 @@ trait GlutenSQLQuerySuiteBase
GlutenTestHiveTables.registerHiveQTestUtilsTables(hiveTestResourceDir)
}
+ testGluten(
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception") {
+ assume(TestUtils.testCommandAvailable("python3"))
+ withTempView("test") {
+ import spark.implicits._
+
+ val defaultUncaughtExceptionHandler =
Thread.getDefaultUncaughtExceptionHandler
+ try {
+ val uncaughtExceptionHandler = new TestUncaughtExceptionHandler
+ Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler)
+
+ // Use a bad udf to generate failed inputs.
+ val badUDF = org.apache.spark.sql.functions.udf(
+ (x: Int) => {
+ if (x < 1) x
+ else throw new RuntimeException("Failed to produce data.")
+ })
+ spark
+ .range(5)
+ .select(badUDF($"id").as("a"))
+ .createOrReplaceTempView("test")
+ val scriptFilePath = hiveResourcePath("data").toFile.getCanonicalPath
+ val e = intercept[SparkException] {
+ sql(
+ s"""FROM test SELECT TRANSFORM(a)
+ |USING 'python3 $scriptFilePath/scripts/test_transform.py "\t"'
+ """.stripMargin).collect()
+ }
+ assert(e.getMessage.contains("Failed to produce data."))
+ assert(uncaughtExceptionHandler.exception.isEmpty)
+ } finally {
+
Thread.setDefaultUncaughtExceptionHandler(defaultUncaughtExceptionHandler)
+ }
+ }
+ }
+
testGluten("script") {
withTempView("script_table") {
import spark.implicits._
diff --git
a/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
b/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
index 9af7bfca46..2571b567d2 100644
---
a/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
+++
b/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
@@ -16,8 +16,9 @@
*/
package org.apache.spark.sql.hive.execution
-import org.apache.spark.TestUtils
+import org.apache.spark.{SparkException, TestUtils}
import org.apache.spark.sql.{GlutenTestSetWithSystemPropertyTrait, Row}
+import org.apache.spark.sql.execution.TestUncaughtExceptionHandler
import org.apache.spark.tags.SlowHiveTest
trait GlutenSQLQuerySuiteBase
@@ -26,9 +27,11 @@ trait GlutenSQLQuerySuiteBase
with GlutenHiveResourcePathSupport {
override def testNameBlackList: Seq[String] = Seq(
- // Rewritten with a workspace-backed script path because
getTestResourcePath resolves
- // test-script.sh from the spark-hive tests jar in gluten-ut.
- "script"
+ // Rewritten with workspace-backed resource paths because the upstream
tests resolve
+ // resources from Spark test jars in gluten-ut.
+ "script",
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception"
)
override def beforeAll(): Unit = {
@@ -36,6 +39,43 @@ trait GlutenSQLQuerySuiteBase
GlutenTestHiveTables.registerHiveQTestUtilsTables(hiveTestResourceDir)
}
+ testGluten(
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception") {
+ assume(TestUtils.testCommandAvailable("python3"))
+ withTempView("test") {
+ import spark.implicits._
+
+ val defaultUncaughtExceptionHandler =
Thread.getDefaultUncaughtExceptionHandler
+ try {
+ val uncaughtExceptionHandler = new TestUncaughtExceptionHandler
+ Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler)
+
+ // Use a bad udf to generate failed inputs.
+ val badUDF = org.apache.spark.sql.functions.udf(
+ (x: Int) => {
+ if (x < 1) x
+ else throw new RuntimeException("Failed to produce data.")
+ })
+ spark
+ .range(5)
+ .select(badUDF($"id").as("a"))
+ .createOrReplaceTempView("test")
+ val scriptFilePath = hiveResourcePath("data").toFile.getCanonicalPath
+ val e = intercept[SparkException] {
+ sql(
+ s"""FROM test SELECT TRANSFORM(a)
+ |USING 'python3 $scriptFilePath/scripts/test_transform.py "\t"'
+ """.stripMargin).collect()
+ }
+ assert(e.getMessage.contains("Failed to produce data."))
+ assert(uncaughtExceptionHandler.exception.isEmpty)
+ } finally {
+
Thread.setDefaultUncaughtExceptionHandler(defaultUncaughtExceptionHandler)
+ }
+ }
+ }
+
testGluten("script") {
withTempView("script_table") {
import spark.implicits._
diff --git
a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
index 9af7bfca46..1f981c2723 100644
---
a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
+++
b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/hive/execution/GlutenSQLQuerySuite.scala
@@ -16,8 +16,9 @@
*/
package org.apache.spark.sql.hive.execution
-import org.apache.spark.TestUtils
+import org.apache.spark.{SparkException, TestUtils}
import org.apache.spark.sql.{GlutenTestSetWithSystemPropertyTrait, Row}
+import org.apache.spark.sql.execution.TestUncaughtExceptionHandler
import org.apache.spark.tags.SlowHiveTest
trait GlutenSQLQuerySuiteBase
@@ -26,9 +27,11 @@ trait GlutenSQLQuerySuiteBase
with GlutenHiveResourcePathSupport {
override def testNameBlackList: Seq[String] = Seq(
- // Rewritten with a workspace-backed script path because
getTestResourcePath resolves
- // test-script.sh from the spark-hive tests jar in gluten-ut.
- "script"
+ // Rewritten with workspace-backed resource paths because the upstream
tests resolve
+ // resources from Spark test jars in gluten-ut.
+ "script",
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception"
)
override def beforeAll(): Unit = {
@@ -36,6 +39,43 @@ trait GlutenSQLQuerySuiteBase
GlutenTestHiveTables.registerHiveQTestUtilsTables(hiveTestResourceDir)
}
+ testGluten(
+ "SPARK-25158: " +
+ "Executor accidentally exit because ScriptTransformationWriterThread
throw Exception") {
+ assume(TestUtils.testCommandAvailable("python3"))
+ withTempView("test") {
+ import spark.implicits._
+
+ val defaultUncaughtExceptionHandler =
Thread.getDefaultUncaughtExceptionHandler
+ try {
+ val uncaughtExceptionHandler = new TestUncaughtExceptionHandler
+ Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler)
+
+ // Use a bad udf to generate failed inputs.
+ val badUDF = org.apache.spark.sql.functions.udf(
+ (x: Int) => {
+ if (x < 1) x
+ else throw new RuntimeException("Failed to produce data.")
+ })
+ spark
+ .range(5)
+ .select(badUDF($"id").as("a"))
+ .createOrReplaceTempView("test")
+ val scriptFilePath = hiveResourcePath("data").toFile.getCanonicalPath
+ val e = intercept[SparkException] {
+ sql(
+ s"""FROM test SELECT TRANSFORM(a)
+ |USING 'python3 $scriptFilePath/scripts/do_transform.py "\t"'
+ """.stripMargin).collect()
+ }
+ assert(e.getMessage.contains("Failed to produce data."))
+ assert(uncaughtExceptionHandler.exception.isEmpty)
+ } finally {
+
Thread.setDefaultUncaughtExceptionHandler(defaultUncaughtExceptionHandler)
+ }
+ }
+ }
+
testGluten("script") {
withTempView("script_table") {
import spark.implicits._
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]