Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6665,14 +6665,15 @@ object SQLConf {
.createWithDefault(false)

val UI_EXPLAIN_MODE = buildConf("spark.sql.ui.explainMode")
.doc("Configures the query explain mode used in the Spark SQL UI. The value can be 'simple', " +
"'extended', 'codegen', 'cost', or 'formatted'. The default value is 'formatted'.")
.doc("Configures the query explain mode used in the Spark SQL UI. The value can be 'none', " +
"'simple', 'extended', 'codegen', 'cost', or 'formatted'. The default value is 'formatted'.")
.version("3.1.0")
.stringConf
.transform(_.toUpperCase(Locale.ROOT))
.checkValue(mode => Set("SIMPLE", "EXTENDED", "CODEGEN", "COST", "FORMATTED").contains(mode),
"Invalid value for 'spark.sql.ui.explainMode'. Valid values are 'simple', 'extended', " +
"'codegen', 'cost' and 'formatted'.")
.checkValue(mode =>
Set("NONE", "SIMPLE", "EXTENDED", "CODEGEN", "COST", "FORMATTED").contains(mode),
"Invalid value for 'spark.sql.ui.explainMode'. Valid values are 'none', 'simple', " +
"'extended', 'codegen', 'cost' and 'formatted'.")
.createWithDefault("formatted")

val SOURCES_BINARY_FILE_MAX_LENGTH = buildConf("spark.sql.sources.binaryFile.maxLength")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,12 @@ object SQLExecution extends Logging {
sc.listenerBus.post(startEvent)
throw e
case Right(f) =>
val planDescriptionMode =
ExplainMode.fromString(sparkSession.sessionState.conf.uiExplainMode)
val planDesc = queryExecution.explainString(planDescriptionMode)
val planDescriptionMode = {
val mode = sparkSession.sessionState.conf.uiExplainMode
if (mode == "NONE") None else Some(ExplainMode.fromString(mode))
}
val planDesc = planDescriptionMode.map(queryExecution.explainString).getOrElse(
"No plan description because spark.sql.ui.explainMode=none")
val planInfo = try {
SparkPlanInfo.fromSparkPlan(queryExecution.executedPlan)
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1145,10 +1145,14 @@ case class AdaptiveSparkPlanExec(
context.session.sparkContext.listenerBus.post(SparkListenerSQLAdaptiveSQLMetricUpdates(
executionId, newMetrics))
} else {
val planDescriptionMode = ExplainMode.fromString(conf.uiExplainMode)
val planDescription = if (conf.uiExplainMode == "NONE") {
"No plan description because spark.sql.ui.explainMode=none"
} else {
context.qe.explainString(ExplainMode.fromString(conf.uiExplainMode))
}
context.session.sparkContext.listenerBus.post(SparkListenerSQLAdaptiveExecutionUpdate(
executionId,
context.qe.explainString(planDescriptionMode),
planDescription,
SparkPlanInfo.fromSparkPlan(context.qe.executedPlan)))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2541,7 +2541,8 @@ class AdaptiveQueryExecSuite
"== Optimized Logical Plan ==", "== Physical Plan ==")),
("codegen", Seq("WholeStageCodegen subtrees")),
("cost", Seq("== Optimized Logical Plan ==", "Statistics(sizeInBytes")),
("formatted", Seq("== Physical Plan ==", "Output", "Arguments"))).foreach {
("formatted", Seq("== Physical Plan ==", "Output", "Arguments")),
("none", Seq("No plan description because spark.sql.ui.explainMode=none"))).foreach {
case (mode, expected) =>
checkPlanDescription(mode, expected)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ abstract class SQLAppStatusListenerSuite extends SharedSparkSession with JsonTes
"== Optimized Logical Plan ==", "== Physical Plan ==")),
("codegen", Seq("WholeStageCodegen subtrees")),
("cost", Seq("== Optimized Logical Plan ==", "Statistics(sizeInBytes")),
("formatted", Seq("== Physical Plan ==", "Output", "Arguments"))).foreach {
("formatted", Seq("== Physical Plan ==", "Output", "Arguments")),
("none", Seq("No plan description because spark.sql.ui.explainMode=none"))).foreach {
case (mode, expected) =>
checkPlanDescription(mode, expected)
}
Expand Down