Skip to content
Closed
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 @@ -119,7 +119,9 @@ object SQLExecution {
// will be caught and reported in the `SparkListenerSQLExecutionEnd`
sparkPlanInfo = SparkPlanInfo.fromSparkPlan(queryExecution.executedPlan),
time = System.currentTimeMillis(),
redactedConfigs))
modifiedConfigs = redactedConfigs,
jobTags = sc.getJobTags()
))
body
} catch {
case e: Throwable =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class SQLAppStatusListener(

private def onExecutionStart(event: SparkListenerSQLExecutionStart): Unit = {
val SparkListenerSQLExecutionStart(executionId, rootExecutionId, description, details,
physicalPlanDescription, sparkPlanInfo, time, modifiedConfigs) = event
physicalPlanDescription, sparkPlanInfo, time, modifiedConfigs, _) = event

val planGraph = SparkPlanGraph(sparkPlanInfo)
val sqlPlanMetrics = planGraph.allNodes.flatMap { node =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ case class SparkListenerSQLExecutionStart(
physicalPlanDescription: String,
sparkPlanInfo: SparkPlanInfo,
time: Long,
modifiedConfigs: Map[String, String] = Map.empty)
modifiedConfigs: Map[String, String] = Map.empty,
jobTags: Set[String] = Set.empty)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: where will the jobTags in SparkListenerSQLExecutionStart event be used?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a followup to #41964, currently SQL Executions associated with a Spark Connect execution are found by using the EXECUTION_ID_KEY of corresponding Spark Jobs.
There are however various Spark Connect executions that start SQL Execution without starting a Spark Job. For example various commands like SHOW TABLES. Currently with #41964 the SQL Executions of these will not be linked from the Connect tab. With the jobTag, they can be now identified using the Spark Connect tag. Since this PR is almost ready to merge (hope CI will finish soon), I think using it for the Connect tab could be done in a followup PR?

extends SparkListenerEvent

@DeveloperApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,36 @@ class SQLExecutionSuite extends SparkFunSuite {
spark.stop()
}
}

test("SPARK-44591: jobTags property") {
val spark = SparkSession.builder.master("local[*]").appName("test").getOrCreate()
val jobTag = "jobTag"
try {
spark.sparkContext.addJobTag(jobTag)

var jobTags: Option[String] = None
var sqlJobTags: Set[String] = Set.empty
spark.sparkContext.addSparkListener(new SparkListener {
override def onJobStart(jobStart: SparkListenerJobStart): Unit = {
jobTags = Some(jobStart.properties.getProperty(SparkContext.SPARK_JOB_TAGS))
}
override def onOtherEvent(event: SparkListenerEvent): Unit = {
event match {
case e: SparkListenerSQLExecutionStart =>
sqlJobTags = e.jobTags
}
}
})

spark.range(1).collect()

assert(jobTags.contains(jobTag))
assert(sqlJobTags.contains(jobTag))
} finally {
spark.sparkContext.removeJobTag(jobTag)
spark.stop()
}
}
}

object SQLExecutionSuite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ abstract class SQLAppStatusListenerSuite extends SharedSparkSession with JsonTes
val listener = new SparkListener {
override def onOtherEvent(event: SparkListenerEvent): Unit = {
event match {
case SparkListenerSQLExecutionStart(_, _, _, _, planDescription, _, _, _) =>
case SparkListenerSQLExecutionStart(_, _, _, _, planDescription, _, _, _, _) =>
assert(expected.forall(planDescription.contains))
checkDone = true
case _ => // ignore other events
Expand Down