Pajaraja commented on code in PR #50803: URL: https://github.com/apache/spark/pull/50803#discussion_r2077250730
########## sql/core/src/test/resources/sql-tests/results/cte-recursion.sql.out: ########## @@ -325,10 +325,13 @@ SELECT * FROM t -- !query schema struct<> -- !query output -org.apache.spark.sql.catalyst.ExtendedAnalysisException +org.apache.spark.SparkException Review Comment: Added Limit. ########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala: ########## @@ -603,11 +603,21 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] /** * A variant of `collect`. This method not only apply the given function to all elements in this - * plan, also considering all the plans in its (nested) subqueries + * plan, also considering all the plans in its (nested) subqueries. */ def collectWithSubqueries[B](f: PartialFunction[PlanType, B]): Seq[B] = (this +: subqueriesAll).flatMap(_.collect(f)) + /** + * A variant of collectFirst. This method not only apply the given function to all elements in + * this plan, also considering all the plans in its (nested) subqueries. + */ + def collectFirstWithSubqueries[B](f: PartialFunction[PlanType, B]): Option[B] = { + this.collectFirst(f).orElse { + subqueriesAll.foldLeft(Option.empty[B]) { (l, r) => l.orElse(r.collectFirst(f)) } Review Comment: Added this. -- 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: reviews-unsubscr...@spark.apache.org 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