You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/07 05:25:37 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #32032: [SPARK-34701][SQL] Introduce AnalysisOnlyCommand that allows its children to be removed once the command is marked as analyzed.

cloud-fan commented on a change in pull request #32032:
URL: https://github.com/apache/spark/pull/32032#discussion_r608348517



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/Command.scala
##########
@@ -37,3 +38,35 @@ trait Command extends LogicalPlan {
 trait LeafCommand extends Command with LeafLike[LogicalPlan]
 trait UnaryCommand extends Command with UnaryLike[LogicalPlan]
 trait BinaryCommand extends Command with BinaryLike[LogicalPlan]
+
+/**
+ * A logical node that represents a command whose children are only analyzed, but not optimized.
+ */
+trait AnalysisOnlyCommand extends Command {
+  private var _isAnalyzed: Boolean = false
+
+  def childrenToAnalyze: Seq[LogicalPlan]
+
+  override def children: Seq[LogicalPlan] = if (_isAnalyzed) Nil else childrenToAnalyze

Review comment:
       This is tricky because the `children` can change dynamically. I was expecting to put `isAnalyzed` as a case class parameter, so `markAsAnalyzed` creates a new copy and the plan node is still immutable. We can avoid changing `TreeNode` if we do so.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org