-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-39635][SQL] Support driver metrics in DS v2 custom metric API #37205
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
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 |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ import org.apache.spark.sql.catalyst.plans.physical | |
| import org.apache.spark.sql.catalyst.plans.physical.{KeyGroupedPartitioning, SinglePartition} | ||
| import org.apache.spark.sql.catalyst.util.truncatedString | ||
| import org.apache.spark.sql.connector.read.{HasPartitionKey, InputPartition, PartitionReaderFactory, Scan} | ||
| import org.apache.spark.sql.execution.{ExplainUtils, LeafExecNode} | ||
| import org.apache.spark.sql.execution.{ExplainUtils, LeafExecNode, SQLExecution} | ||
| import org.apache.spark.sql.execution.metric.SQLMetrics | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.sql.internal.connector.SupportsMetadata | ||
|
|
@@ -168,6 +168,18 @@ trait DataSourceV2ScanExecBase extends LeafExecNode { | |
| } | ||
| } | ||
|
|
||
| protected def postDriverMetrics(): Unit = { | ||
| val driveSQLMetrics = scan.reportDriverMetrics().map(customTaskMetric => { | ||
| val metric = metrics(customTaskMetric.name()) | ||
|
||
| metric.set(customTaskMetric.value()) | ||
| metric | ||
| }) | ||
|
|
||
| val executionId = sparkContext.getLocalProperty(SQLExecution.EXECUTION_ID_KEY) | ||
| SQLMetrics.postDriverMetricUpdates(sparkContext, executionId, | ||
| driveSQLMetrics) | ||
| } | ||
|
|
||
| override def doExecuteColumnar(): RDD[ColumnarBatch] = { | ||
| val numOutputRows = longMetric("numOutputRows") | ||
| inputRDD.asInstanceOf[RDD[ColumnarBatch]].map { b => | ||
|
|
||
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.
Except for
BatchScanExec, there seems other places we need doing this too. E.g.,MicroBatchScanExec,ContinuousScanExecwhich are based onDataSourceV2ScanExecBase.Uh oh!
There was an error while loading. Please reload this page.
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.
For writer, there is
V2TableWriteExec,V2ExistingTableWriteExec,WriteToContinuousDataSourceExec.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.
+1
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.
@viirya @cloud-fan I will create a follow up PR for the write paths.
As for read paths, I have updated ContinuousScanExec, MicroBatchScanExec similar to BatchScanExec.
Can you please point me to test case that I can run to verify if the behavior is as expected.