This is an automated email from the ASF dual-hosted git repository.

LuciferYang 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 b6fbc82d88 [GLUTEN-13758][CORE] Fall back to default parallelism in 
getTotalCores for other masters (#13759)
b6fbc82d88 is described below

commit b6fbc82d88797ab091640d5fdb7d32f744db0963
Author: YangJie <[email protected]>
AuthorDate: Wed Nov 25 10:30:30 2026 -0500

    [GLUTEN-13758][CORE] Fall back to default parallelism in getTotalCores for 
other masters (#13759)
    
    ## What changes are proposed in this pull request?
    
    `SparkResourceUtil.getTotalCores` had no default case in its match on 
`spark.master`, so any master other than `local*`, `yarn`, `k8s:` or `spark:` 
threw `scala.MatchError`. That covers `mesos://` on Spark 3.4/3.5 and masters 
provided by an `ExternalClusterManager`. The ClickHouse backend calls it 
whenever it builds file partitions, so file scans failed on those masters.
    
    Those masters now fall back to `spark.default.parallelism`, the same value 
the `local` case uses.
    
    Fixes #13758.
    
    ## How was this patch tested?
    
    Added a test to `SparkResourceUtilSuite` that sets `spark.master` to 
`mesos://host:5050` and checks that `getTotalCores` returns 
`spark.default.parallelism`. It fails with `MatchError` on the old code.
    
    ## Was this patch authored or co-authored using generative AI tooling?
    
    Yes. Generated-by: Claude Opus.
---
 .../src/main/scala/org/apache/spark/util/SparkResourceUtil.scala  | 3 +++
 .../test/scala/org/apache/spark/util/SparkResourceUtilSuite.scala | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git 
a/gluten-core/src/main/scala/org/apache/spark/util/SparkResourceUtil.scala 
b/gluten-core/src/main/scala/org/apache/spark/util/SparkResourceUtil.scala
index c27000beca..92bf545dd5 100644
--- a/gluten-core/src/main/scala/org/apache/spark/util/SparkResourceUtil.scala
+++ b/gluten-core/src/main/scala/org/apache/spark/util/SparkResourceUtil.scala
@@ -39,6 +39,9 @@ object SparkResourceUtil extends Logging {
         Math.max(
           sqlConf.getConfString("spark.cores.max", "1").toInt,
           sqlConf.getConfString("spark.default.parallelism", "1").toInt)
+      case _ =>
+        // Other cluster managers, e.g. mesos:// or one plugged in through 
ExternalClusterManager.
+        sqlConf.getConfString("spark.default.parallelism", "1").toInt
     }
   }
 
diff --git 
a/gluten-core/src/test/scala/org/apache/spark/util/SparkResourceUtilSuite.scala 
b/gluten-core/src/test/scala/org/apache/spark/util/SparkResourceUtilSuite.scala
index 48d10abe9a..8d6479a466 100644
--- 
a/gluten-core/src/test/scala/org/apache/spark/util/SparkResourceUtilSuite.scala
+++ 
b/gluten-core/src/test/scala/org/apache/spark/util/SparkResourceUtilSuite.scala
@@ -17,11 +17,19 @@
 package org.apache.spark.util
 
 import org.apache.spark.SparkConf
+import org.apache.spark.sql.internal.SQLConf
 
 import org.scalatest.funsuite.AnyFunSuite
 
 class SparkResourceUtilSuite extends AnyFunSuite {
 
+  test("getTotalCores falls back to default parallelism for other cluster 
managers") {
+    val conf = new SQLConf
+    conf.setConfString("spark.master", "mesos://host:5050")
+    conf.setConfString("spark.default.parallelism", "7")
+    assert(SparkResourceUtil.getTotalCores(conf) == 7)
+  }
+
   test("getTaskSlots floors at one when task cpus exceed executor cores") {
     // spark.task.cpus > executor cores is an invalid config that Spark 
rejects later, but Gluten
     // reads task slots during plugin init and divides by the result. 
Returning 0 here makes that


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to