peter-toth commented on a change in pull request #23531: [SPARK-24497][SQL]
Support recursive SQL query
URL: https://github.com/apache/spark/pull/23531#discussion_r286966993
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/basicPhysicalOperators.scala
##########
@@ -228,6 +232,95 @@ case class FilterExec(condition: Expression, child:
SparkPlan)
override def outputPartitioning: Partitioning = child.outputPartitioning
}
+/** Physical plan for RecursiveTable. */
+case class RecursiveTableExec(
+ name: String,
+ anchorTerms: Seq[SparkPlan],
+ recursiveTerms: Seq[LogicalPlan],
+ limit: Option[Long]) extends SparkPlan {
+ override def children: Seq[SparkPlan] = anchorTerms
+
+ override def output: Seq[Attribute] =
anchorTerms.head.output.map(_.withNullability(true))
+
+ override def simpleString(maxFields: Int): String =
+ s"RecursiveTable $name${limit.map(", " + _).getOrElse("")}"
+
+ override def innerChildren: Seq[LogicalPlan] = recursiveTerms
+
+ override protected def doExecute(): RDD[InternalRow] = {
+ val prevIterationRDDs = ArrayBuffer.empty[RDD[InternalRow]]
+ var prevIterationCount = 0L
+ val anchorTermsIterator = anchorTerms.iterator
+ while (anchorTermsIterator.hasNext && limit.forall(_ >
prevIterationCount)) {
+ val anchorTerm = anchorTermsIterator.next()
+
+ val rdd = anchorTerm.execute().map(_.copy()).cache()
Review comment:
good idea, I've added a new config
`spark.sql.cte.recursion.cache.storageLevel`
----------------------------------------------------------------
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]