You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2026/04/28 20:27:37 UTC
(spark) branch master updated: [SPARK-56587][SQL] Show table names for V2 write nodes in UI
This is an automated email from the ASF dual-hosted git repository.
dongjoon-hyun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 9bae5a1ecf27 [SPARK-56587][SQL] Show table names for V2 write nodes in UI
9bae5a1ecf27 is described below
commit 9bae5a1ecf27d6a7228fdc230aec6aa8d07fd171
Author: Yuming Wang <yu...@apache.org>
AuthorDate: Tue Apr 28 13:27:27 2026 -0700
[SPARK-56587][SQL] Show table names for V2 write nodes in UI
### What changes were proposed in this pull request?
This PR modifies the physical execution nodes for DataSourceV2 write operations (such as `AppendDataExec`, `OverwriteByExpressionExec`, `OverwritePartitionsDynamicExec`, `ReplaceDataExec`, and `WriteDeltaExec`) to accept and store the destination `tableName`. It then updates the `nodeName` property in the base `V2ExistingTableWriteExec` trait to include this table name in its output.
### Why are the changes needed?
To improve observability and debuggability in the Spark SQL UI and Explain plans. Previously, V2 write nodes were displayed generically (e.g., `AppendData`). With this change, the UI will explicitly show the context of the write operation (e.g., `AppendData catalog.namespace.table_name`), making it much easier for users to understand which tables are being modified.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Unit test and manual test:
<img width="546" height="710" alt="image" src="https://github.com/user-attachments/assets/d9202153-eefe-45a0-8464-114cd06501e6" />
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #55510 from wangyum/SPARK-56587.
Authored-by: Yuming Wang <yu...@apache.org>
Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
.../datasources/v2/DataSourceV2Strategy.scala | 12 +++++++-----
.../datasources/v2/WriteToDataSourceV2Exec.scala | 18 +++++++++++++-----
.../sql/connector/DataSourceV2OptionSuite.scala | 16 ++++++++--------
.../spark/sql/connector/DataSourceV2SQLSuite.scala | 22 ++++++++++++++++++++++
4 files changed, 50 insertions(+), 18 deletions(-)
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
index d677ff1c4be2..e03928867e24 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
@@ -423,7 +423,7 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat
}
case AppendData(r: DataSourceV2Relation, query, _, _, _, Some(write), _) =>
- AppendDataExec(planLater(query), refreshCache(r), write) :: Nil
+ AppendDataExec(planLater(query), refreshCache(r), write, r.name) :: Nil
case OverwriteByExpression(r @ ExtractV2Table(v1: SupportsWrite), _, _,
_, _, _, Some(write), analyzedQuery) if v1.supports(TableCapability.V1_BATCH_WRITE) =>
@@ -438,10 +438,10 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat
case OverwriteByExpression(
r: DataSourceV2Relation, _, query, _, _, _, Some(write), _) =>
- OverwriteByExpressionExec(planLater(query), refreshCache(r), write) :: Nil
+ OverwriteByExpressionExec(planLater(query), refreshCache(r), write, r.name) :: Nil
case OverwritePartitionsDynamic(r: DataSourceV2Relation, query, _, _, _, Some(write)) =>
- OverwritePartitionsDynamicExec(planLater(query), refreshCache(r), write) :: Nil
+ OverwritePartitionsDynamicExec(planLater(query), refreshCache(r), write, r.name) :: Nil
case DeleteFromTableWithFilters(r: DataSourceV2Relation, filters) =>
DeleteFromTableExec(r.table.asDeletable, filters.toArray, refreshCache(r)) :: Nil
@@ -487,7 +487,8 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat
refreshCache(r), // use the original relation to refresh the cache
projections,
write,
- rd.operation.command) :: Nil
+ rd.operation.command,
+ r.name) :: Nil
case wd @ WriteDelta(_: DataSourceV2Relation, _, query, r: DataSourceV2Relation, projections,
Some(write)) =>
@@ -496,7 +497,8 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat
refreshCache(r), // use the original relation to refresh the cache
projections,
write,
- wd.operation.command) :: Nil
+ wd.operation.command,
+ r.name) :: Nil
case MergeRows(isSourceRowPresent, isTargetRowPresent, matchedInstructions,
notMatchedInstructions, notMatchedBySourceInstructions, checkCardinality, output, child) =>
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/WriteToDataSourceV2Exec.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/WriteToDataSourceV2Exec.scala
index 6bb1eb6f4b6d..2071024c5b7e 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/WriteToDataSourceV2Exec.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/WriteToDataSourceV2Exec.scala
@@ -272,7 +272,8 @@ case class AtomicReplaceTableAsSelectExec(
case class AppendDataExec(
query: SparkPlan,
refreshCache: () => Unit,
- write: Write) extends V2ExistingTableWriteExec {
+ write: Write,
+ tableName: String) extends V2ExistingTableWriteExec {
override protected def withNewChildInternal(newChild: SparkPlan): AppendDataExec =
copy(query = newChild)
}
@@ -290,7 +291,8 @@ case class AppendDataExec(
case class OverwriteByExpressionExec(
query: SparkPlan,
refreshCache: () => Unit,
- write: Write) extends V2ExistingTableWriteExec {
+ write: Write,
+ tableName: String) extends V2ExistingTableWriteExec {
override protected def withNewChildInternal(newChild: SparkPlan): OverwriteByExpressionExec =
copy(query = newChild)
}
@@ -307,7 +309,8 @@ case class OverwriteByExpressionExec(
case class OverwritePartitionsDynamicExec(
query: SparkPlan,
refreshCache: () => Unit,
- write: Write) extends V2ExistingTableWriteExec {
+ write: Write,
+ tableName: String) extends V2ExistingTableWriteExec {
override protected def withNewChildInternal(newChild: SparkPlan): OverwritePartitionsDynamicExec =
copy(query = newChild)
}
@@ -320,7 +323,8 @@ case class ReplaceDataExec(
refreshCache: () => Unit,
projections: ReplaceDataProjections,
write: Write,
- rowLevelCommand: RowLevelOperation.Command) extends RowLevelWriteExec {
+ rowLevelCommand: RowLevelOperation.Command,
+ tableName: String) extends RowLevelWriteExec {
override def writingTask: WritingSparkTask[_] = {
projections.metadataProjection match {
@@ -364,7 +368,8 @@ case class WriteDeltaExec(
refreshCache: () => Unit,
projections: WriteDeltaProjections,
write: DeltaWrite,
- rowLevelCommand: RowLevelOperation.Command) extends RowLevelWriteExec {
+ rowLevelCommand: RowLevelOperation.Command,
+ tableName: String) extends RowLevelWriteExec {
override lazy val writingTask: WritingSparkTask[_] = {
if (projections.metadataProjection.isDefined) {
@@ -404,9 +409,12 @@ case class WriteToDataSourceV2Exec(
trait V2ExistingTableWriteExec extends V2TableWriteExec {
def refreshCache: () => Unit
def write: Write
+ def tableName: String
override def stringArgs: Iterator[Any] = Iterator(query, write)
+ override def nodeName: String = s"${super.nodeName} $tableName"
+
override val customMetrics: Map[String, SQLMetric] =
write.supportedCustomMetrics().map { customMetric =>
customMetric.name() -> SQLMetrics.createV2CustomMetric(sparkContext, customMetric)
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2OptionSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2OptionSuite.scala
index 30890200df79..fbcfdfb20c6e 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2OptionSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2OptionSuite.scala
@@ -109,7 +109,7 @@ class DataSourceV2OptionSuite extends DatasourceV2SQLBase {
collected = df.queryExecution.executedPlan.collect {
case CommandResultExec(
- _, AppendDataExec(_, _, write),
+ _, AppendDataExec(_, _, write, _),
_) =>
val append = write.toBatch.asInstanceOf[InMemoryBaseTable#Append]
assert(append.info.options.get("write.split-size") === "10")
@@ -141,7 +141,7 @@ class DataSourceV2OptionSuite extends DatasourceV2SQLBase {
assert (collected.size == 1)
collected = qe.executedPlan.collect {
- case AppendDataExec(_, _, write) =>
+ case AppendDataExec(_, _, write, _) =>
val append = write.toBatch.asInstanceOf[InMemoryBaseTable#Append]
assert(append.info.options.get("write.split-size") === "10")
}
@@ -168,7 +168,7 @@ class DataSourceV2OptionSuite extends DatasourceV2SQLBase {
assert (collected.size == 1)
collected = qe.executedPlan.collect {
- case AppendDataExec(_, _, write) =>
+ case AppendDataExec(_, _, write, _) =>
val append = write.toBatch.asInstanceOf[InMemoryBaseTable#Append]
assert(append.info.options.get("write.split-size") === "10")
}
@@ -194,7 +194,7 @@ class DataSourceV2OptionSuite extends DatasourceV2SQLBase {
collected = df.queryExecution.executedPlan.collect {
case CommandResultExec(
- _, OverwriteByExpressionExec(_, _, write),
+ _, OverwriteByExpressionExec(_, _, write, _),
_) =>
val append = write.toBatch.asInstanceOf[InMemoryBaseTable#TruncateAndAppend]
assert(append.info.options.get("write.split-size") === "10")
@@ -227,7 +227,7 @@ class DataSourceV2OptionSuite extends DatasourceV2SQLBase {
assert (collected.size == 1)
collected = qe.executedPlan.collect {
- case OverwritePartitionsDynamicExec(_, _, write) =>
+ case OverwritePartitionsDynamicExec(_, _, write, _) =>
val dynOverwrite = write.toBatch.asInstanceOf[InMemoryBaseTable#DynamicOverwrite]
assert(dynOverwrite.info.options.get("write.split-size") === "10")
}
@@ -254,7 +254,7 @@ class DataSourceV2OptionSuite extends DatasourceV2SQLBase {
collected = df.queryExecution.executedPlan.collect {
case CommandResultExec(
- _, OverwriteByExpressionExec(_, _, write),
+ _, OverwriteByExpressionExec(_, _, write, _),
_) =>
val append = write.toBatch.asInstanceOf[InMemoryBaseTable#TruncateAndAppend]
assert(append.info.options.get("write.split-size") === "10")
@@ -287,7 +287,7 @@ class DataSourceV2OptionSuite extends DatasourceV2SQLBase {
assert (collected.size == 1)
collected = qe.executedPlan.collect {
- case OverwriteByExpressionExec(_, _, write) =>
+ case OverwriteByExpressionExec(_, _, write, _) =>
val append = write.toBatch.asInstanceOf[InMemoryBaseTable#TruncateAndAppend]
assert(append.info.options.get("write.split-size") === "10")
}
@@ -317,7 +317,7 @@ class DataSourceV2OptionSuite extends DatasourceV2SQLBase {
assert (collected.size == 1)
collected = qe.executedPlan.collect {
- case OverwriteByExpressionExec(_, _, write) =>
+ case OverwriteByExpressionExec(_, _, write, _) =>
val append = write.toBatch.asInstanceOf[InMemoryBaseTable#TruncateAndAppend]
assert(append.info.options.get("write.split-size") === "10")
}
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
index d1dc9c282829..c8f1e2f9ddc2 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
@@ -4302,6 +4302,28 @@ class DataSourceV2SQLSuiteV1Filter
}
}
+ test("SPARK-56587: Show table names for V2 write nodes in UI") {
+ val t1 = s"testcat.ns1.ns2.table_name"
+ withTable(t1) {
+ sql(s"CREATE TABLE $t1 (id bigint, data string) USING foo")
+ val df1 = sql(s"INSERT INTO $t1 VALUES (1, 'a')")
+ val executed1 = df1.queryExecution.executedPlan
+ assert(executed1.collect {
+ case org.apache.spark.sql.execution.CommandResultExec(
+ _, w: org.apache.spark.sql.execution.datasources.v2.V2ExistingTableWriteExec, _) => w
+ case w: org.apache.spark.sql.execution.datasources.v2.V2ExistingTableWriteExec => w
+ }.head.nodeName.contains("testcat.ns1.ns2.table_name"))
+
+ val df2 = sql(s"INSERT OVERWRITE $t1 VALUES (2, 'b')")
+ val executed2 = df2.queryExecution.executedPlan
+ assert(executed2.collect {
+ case org.apache.spark.sql.execution.CommandResultExec(
+ _, w: org.apache.spark.sql.execution.datasources.v2.V2ExistingTableWriteExec, _) => w
+ case w: org.apache.spark.sql.execution.datasources.v2.V2ExistingTableWriteExec => w
+ }.head.nodeName.contains("testcat.ns1.ns2.table_name"))
+ }
+ }
+
private def testNotSupportedV2Command(
sqlCommand: String,
sqlParams: String,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org