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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org