-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-26223][SQL] Track metastore operation time in scan node #23371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ce1b5bc
6214af3
76fcc6a
907882e
358a105
f82b355
b908ecb
abc48a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ import org.apache.spark.{JobExecutionStatus, SparkConf} | |
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.internal.config.Status._ | ||
| import org.apache.spark.scheduler._ | ||
| import org.apache.spark.sql.execution.SQLExecution | ||
| import org.apache.spark.sql.execution.{SparkPlanInfo, SQLExecution} | ||
| import org.apache.spark.sql.execution.metric._ | ||
| import org.apache.spark.sql.internal.StaticSQLConf._ | ||
| import org.apache.spark.status.{ElementTrackingStore, KVUtils, LiveEntity} | ||
|
|
@@ -227,9 +227,9 @@ class SQLAppStatusListener( | |
| } | ||
| } | ||
|
|
||
| private def onExecutionStart(event: SparkListenerSQLExecutionStart): Unit = { | ||
| val SparkListenerSQLExecutionStart(executionId, description, details, | ||
| physicalPlanDescription, sparkPlanInfo, time) = event | ||
| private def createAndStorePlanGraph( | ||
| executionId: Long, | ||
| planInfo: SparkPlanInfo): SparkPlanGraph = { | ||
|
|
||
| def toStoredNodes(nodes: Seq[SparkPlanGraphNode]): Seq[SparkPlanGraphNodeWrapper] = { | ||
| nodes.map { | ||
|
|
@@ -247,17 +247,25 @@ class SQLAppStatusListener( | |
| } | ||
| } | ||
|
|
||
| val planGraph = SparkPlanGraph(sparkPlanInfo) | ||
| val sqlPlanMetrics = planGraph.allNodes.flatMap { node => | ||
| node.metrics.map { metric => (metric.accumulatorId, metric) } | ||
| }.toMap.values.toList | ||
|
|
||
| val planGraph = SparkPlanGraph(planInfo) | ||
| val graphToStore = new SparkPlanGraphWrapper( | ||
| executionId, | ||
| toStoredNodes(planGraph.nodes), | ||
| planGraph.edges) | ||
| kvstore.write(graphToStore) | ||
|
|
||
| planGraph | ||
| } | ||
|
|
||
| private def onExecutionStart(event: SparkListenerSQLExecutionStart): Unit = { | ||
| val SparkListenerSQLExecutionStart(executionId, description, details, | ||
| physicalPlanDescription, sparkPlanInfo, time) = event | ||
|
|
||
| val planGraph = createAndStorePlanGraph(executionId, sparkPlanInfo) | ||
| val sqlPlanMetrics = planGraph.allNodes.flatMap { node => | ||
| node.metrics.map { metric => (metric.accumulatorId, metric) } | ||
| }.toMap.values.toList | ||
|
|
||
| val exec = getOrCreateExecution(executionId) | ||
| exec.description = description | ||
| exec.details = details | ||
|
|
@@ -273,6 +281,12 @@ class SQLAppStatusListener( | |
| exec.metricsValues = aggregateMetrics(exec) | ||
| exec.completionTime = Some(new Date(time)) | ||
| exec.endEvents += 1 | ||
| // Update both physicalPlanDescription and planGraph while the description changed. | ||
|
||
| if (event.planDescUpdate.isDefined) { | ||
| exec.physicalPlanDescription = event.planDescUpdate.get | ||
| kvstore.delete(classOf[SparkPlanGraphWrapper], executionId) | ||
| createAndStorePlanGraph(executionId, event.planInfoUpdate.get) | ||
| } | ||
| update(exec) | ||
|
|
||
| // Remove stale LiveStageMetrics objects for stages that are not active anymore. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using table metadata to carry this information is not a good idea. Can we track it at the caller side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, as the catalog table case class used as the cache key, I also hit some problem before
f82b355 b908ecb.
How about tracking them by QueryPlanningTracker, and use the case class as the key of the phase map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the key is the phase name, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key should be catalog table, it's the same problem with #23327 (comment). I'll address this after the conclusion made.