maryannxue commented on a change in pull request #24706: [SPARK-23128][SQL] A
new approach to do adaptive execution in Spark SQL
URL: https://github.com/apache/spark/pull/24706#discussion_r288201522
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkPlan.scala
##########
@@ -79,6 +81,34 @@ abstract class SparkPlan extends QueryPlan[SparkPlan] with
Logging with Serializ
super.makeCopy(newArgs)
}
+ /**
+ * @return The logical plan this plan is linked to.
+ */
+ def logicalLink: Option[LogicalPlan] =
+ getTagValue(SparkPlan.LOGICAL_PLAN_TAG)
+ .orElse(getTagValue(SparkPlan.LOGICAL_PLAN_INHERITED_TAG))
+
+ /**
+ * Set logical plan link recursively if unset.
+ */
+ def setLogicalLink(logicalPlan: LogicalPlan): Unit = {
+ setLogicalLink(logicalPlan, false)
+ }
+
+ private def setLogicalLink(logicalPlan: LogicalPlan, inherited: Boolean =
false): Unit = {
+ if (logicalLink.isDefined) {
+ return
+ }
+
+ val tag = if (inherited) {
+ SparkPlan.LOGICAL_PLAN_INHERITED_TAG
+ } else {
+ SparkPlan.LOGICAL_PLAN_TAG
+ }
+ setTagValue(tag, logicalPlan)
+ children.foreach(_.setLogicalLink(logicalPlan, true))
Review comment:
Yes. That's true. And you could always "force set" this logical link if need
be.
It's not necessary to draw a line between "logical plan" and "inherited
logical plan" for the use of adaptive execution, so this is simply to make sure
any future use of it can tell a top node from the rest.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]