Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/7920#discussion_r36267171
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala
---
@@ -22,11 +22,60 @@ import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.catalyst.analysis._
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans.QueryPlan
-import org.apache.spark.sql.catalyst.trees.TreeNode
+import org.apache.spark.sql.catalyst.trees.{CurrentOrigin, TreeNode}
abstract class LogicalPlan extends QueryPlan[LogicalPlan] with Logging {
+ private var _analyzed: Boolean = false
+
+ /**
+ * Marks this plan as already analyzed. This should only be called by
CheckAnalysis.
+ */
+ private[catalyst] def setAnalyzed(): Unit = { _analyzed = true }
+
+ /**
+ * Returns true if this node and its children have already been gone
through analysis and
+ * verification. Note that this is only an optimization used to avoid
analyzing trees that
+ * have already been analyzed, and can be reset by transformations.
+ */
+ def analyzed: Boolean = _analyzed
+
+ /**
+ * Returns a copy of this node where `rule` has been recursively applied
first to all of its
+ * children and then itself (post-order). When `rule` does not apply to
a given node, it is left
+ * unchanged. This function is similar to `transformUp`, but skips
sub-trees that have already
+ * been marked as analyzed.
+ *
+ * @param rule the function use to transform this nodes children
+ */
+ def resolveOperators(rule: PartialFunction[LogicalPlan, LogicalPlan]):
LogicalPlan = {
+ if (!analyzed) {
+ val afterRuleOnChildren = transformChildren(rule, (t, r) =>
t.resolveOperators(r))
+ if (this fastEquals afterRuleOnChildren) {
+ CurrentOrigin.withOrigin(origin) {
+ rule.applyOrElse(this, identity[LogicalPlan])
+ }
+ } else {
+ CurrentOrigin.withOrigin(origin) {
+ rule.applyOrElse(afterRuleOnChildren, identity[LogicalPlan])
+ }
+ }
+ } else {
+ this
+ }
+ }
+
+ /**
+ * Recursively transforms the expressions of a tree, skipping nodes that
have already
+ * been analyzed.
+ */
--- End diff --
Seems this method is used to transform expressions using `r` for the entire
logical plan tree?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]