davidm-db commented on code in PR #47403:
URL: https://github.com/apache/spark/pull/47403#discussion_r1686780223
##########
sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionNode.scala:
##########
@@ -91,21 +105,41 @@ class SingleStatementExec(
}
override def reset(): Unit = isExecuted = false
+
+ def execute(session: SparkSession): Unit = {
+ isExecuted = true
+ val rows = Some(Dataset.ofRows(session, parsedPlan).collect())
+ if (shouldCollectResult) {
+ result = rows
+ }
+ }
}
/**
- * Abstract class for all statements that contain nested statements.
- * Implements recursive iterator logic over all child execution nodes.
- * @param collection
- * Collection of child execution nodes.
+ * Executable node for CompoundBody.
+ * @param statements
+ * Executable nodes for nested statements within the CompoundBody.
+ * @param session
+ * Spark session.
*/
-abstract class CompoundNestedStatementIteratorExec(collection:
Seq[CompoundStatementExec])
+class CompoundBodyExec(
+ statements: Seq[CompoundStatementExec],
+ session: SparkSession)
extends NonLeafStatementExec {
- private var localIterator = collection.iterator
- private var curr = if (localIterator.hasNext) Some(localIterator.next())
else None
+ protected var localIterator: Iterator[CompoundStatementExec] =
statements.iterator
+ protected var curr: Option[CompoundStatementExec] =
+ if (localIterator.hasNext) Some(localIterator.next()) else None
+
+ def getTreeIterator: Iterator[CompoundStatementExec] = treeIterator
- private lazy val treeIterator: Iterator[CompoundStatementExec] =
+ override def reset(): Unit = {
+ statements.foreach(_.reset())
+ localIterator = statements.iterator
+ curr = if (localIterator.hasNext) Some(localIterator.next()) else None
+ }
+
+ protected lazy val treeIterator: Iterator[CompoundStatementExec] =
Review Comment:
nit: can be `private` now.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]