This is an automated email from the ASF dual-hosted git repository.
liujiayi771 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 feb8278c91 [CORE][UI] Skip GlutenPlanFallbackEvent posting when gluten
is disabled (#12027)
feb8278c91 is described below
commit feb8278c913d6d2ee3f0ee3513e4e064c0d28937
Author: Joey <[email protected]>
AuthorDate: Tue May 5 17:39:26 2026 +0800
[CORE][UI] Skip GlutenPlanFallbackEvent posting when gluten is disabled
(#12027)
When spark.gluten.enabled=false (e.g. the vanilla Spark baseline run inside
runQueryAndCompare), GlutenQueryExecutionListener previously still posted
a GlutenPlanFallbackEvent. Because no Gluten rules ran, all nodes appeared
as fallback with the generic reason 'Gluten does not touch it or does not
support it', polluting the event stream.
Fix: early-return before collectQueryExecutionFallbackSummary when the
session's spark.gluten.enabled config is false. The config is read directly
from
qe.sparkSession.sessionState.conf via getConfString to avoid thread-local
SQLConf timing issues in the async listener thread.
Add a regression test that verifies no GlutenPlanFallbackEvent is emitted
when a query is executed with spark.gluten.enabled=false.
---
.../apache/gluten/execution/FallbackSuite.scala | 33 ++++++++++++++++++++++
.../execution/GlutenQueryExecutionListener.scala | 13 +++++++++
2 files changed, 46 insertions(+)
diff --git
a/backends-velox/src/test/scala/org/apache/gluten/execution/FallbackSuite.scala
b/backends-velox/src/test/scala/org/apache/gluten/execution/FallbackSuite.scala
index b77c8c2f08..5250ab7df7 100644
---
a/backends-velox/src/test/scala/org/apache/gluten/execution/FallbackSuite.scala
+++
b/backends-velox/src/test/scala/org/apache/gluten/execution/FallbackSuite.scala
@@ -387,4 +387,37 @@ class FallbackSuite extends
VeloxWholeStageTransformerSuite with AdaptiveSparkPl
spark.sparkContext.removeSparkListener(listener)
}
}
+
+ test("no fallback event emitted for vanilla Spark execution with gluten
disabled") {
+ // Regression test: before the fix, GlutenQueryExecutionListener would
post a
+ // GlutenPlanFallbackEvent even when spark.gluten.enabled=false (e.g. the
vanilla baseline run
+ // inside runQueryAndCompare). All nodes would appear as fallback with the
generic reason
+ // "Gluten does not touch it or does not support it".
+ val events = new ArrayBuffer[GlutenPlanFallbackEvent]
+ val listener = new SparkListener {
+ override def onOtherEvent(event: SparkListenerEvent): Unit = {
+ event match {
+ case e: GlutenPlanFallbackEvent => events.append(e)
+ case _ =>
+ }
+ }
+ }
+ spark.sparkContext.addSparkListener(listener)
+ try {
+ // Execute a query with gluten disabled — this mimics what
runQueryAndCompare does for the
+ // vanilla baseline run. No GlutenPlanFallbackEvent should be emitted at
all.
+ withSQLConf(GlutenConfig.GLUTEN_ENABLED.key -> "false") {
+ spark.sql("SELECT c1, count(*) FROM tmp1 GROUP BY c1").collect()
+ }
+ GlutenSuiteUtils.waitUntilEmpty(spark.sparkContext)
+ assert(
+ events.isEmpty,
+ s"Expected no GlutenPlanFallbackEvent for vanilla Spark execution, " +
+ s"but got ${events.size} event(s). " +
+ s"First event fallback reasons:
${events.headOption.map(_.fallbackNodeToReason)}"
+ )
+ } finally {
+ spark.sparkContext.removeSparkListener(listener)
+ }
+ }
}
diff --git
a/gluten-substrait/src/main/scala/org/apache/spark/sql/execution/GlutenQueryExecutionListener.scala
b/gluten-substrait/src/main/scala/org/apache/spark/sql/execution/GlutenQueryExecutionListener.scala
index 32f7ef2cd0..d3b8d14c0e 100644
---
a/gluten-substrait/src/main/scala/org/apache/spark/sql/execution/GlutenQueryExecutionListener.scala
+++
b/gluten-substrait/src/main/scala/org/apache/spark/sql/execution/GlutenQueryExecutionListener.scala
@@ -16,6 +16,7 @@
*/
package org.apache.spark.sql.execution
+import org.apache.gluten.config.GlutenConfig
import org.apache.gluten.events.GlutenPlanFallbackEvent
import org.apache.spark.SparkContext
@@ -40,6 +41,18 @@ class GlutenQueryExecutionListener(sc: SparkContext) extends
SparkListener with
return
}
+ // Skip posting if Gluten was not involved in this query execution.
+ // This can happen when Gluten is disabled via session config (e.g.,
vanilla Spark
+ // baseline runs in comparison tests) but the listener is still
registered globally.
+ // Read directly from qe.sparkSession's conf to avoid thread-local
SQLConf issues.
+ if (
+ !qe.sparkSession.sessionState.conf.getConfString(
+ GlutenConfig.GLUTEN_ENABLED.key,
+ GlutenConfig.GLUTEN_ENABLED.defaultValueString).toBoolean
+ ) {
+ return
+ }
+
val summary =
GlutenImplicits.collectQueryExecutionFallbackSummary(qe.sparkSession,
qe)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]