szehon-ho commented on code in PR #52669:
URL: https://github.com/apache/spark/pull/52669#discussion_r2479157138
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/WriteToDataSourceV2Exec.scala:
##########
@@ -495,6 +498,40 @@ trait V2TableWriteExec extends V2CommandExec with
UnaryExecNode with AdaptiveSpa
)
}
}
+
+ private def getNumSourceRows(mergeRowsExec: MergeRowsExec): Long = {
+ def hasTargetTable(plan: SparkPlan): Boolean = {
+ collectFirst(plan) {
+ case scan @ BatchScanExec(_, _, _, _, _: RowLevelOperationTable, _) =>
scan
+ }.isDefined
+ }
+
+ def findSourceScan(join: BaseJoinExec): Option[SparkPlan] = {
+ val leftHasTarget = hasTargetTable(join.left)
+ val rightHasTarget = hasTargetTable(join.right)
+
+ val sourceSide = if (leftHasTarget) {
+ Some(join.right)
+ } else if (rightHasTarget) {
+ Some(join.left)
+ } else {
+ None
+ }
+
+ sourceSide.flatMap { side =>
Review Comment:
Maybe we don't need this, we want to find the first join child (on source
side) with numOutputRows, else -1?
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/WriteToDataSourceV2Exec.scala:
##########
@@ -495,6 +498,40 @@ trait V2TableWriteExec extends V2CommandExec with
UnaryExecNode with AdaptiveSpa
)
}
}
+
+ private def getNumSourceRows(mergeRowsExec: MergeRowsExec): Long = {
+ def hasTargetTable(plan: SparkPlan): Boolean = {
+ collectFirst(plan) {
+ case scan @ BatchScanExec(_, _, _, _, _: RowLevelOperationTable, _) =>
scan
+ }.isDefined
+ }
+
+ def findSourceScan(join: BaseJoinExec): Option[SparkPlan] = {
Review Comment:
The method name should reflect that its finding the source side child, not
the source itself.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]