davidm-db commented on code in PR #47423:
URL: https://github.com/apache/spark/pull/47423#discussion_r1713946351
##########
sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionNode.scala:
##########
@@ -127,20 +153,116 @@ class SingleStatementExec(
origin.sqlText.get.substring(origin.startIndex.get, origin.stopIndex.get +
1)
}
- override def reset(): Unit = isExecuted = false
+ override def reset(): Unit = {
+ super.reset()
+ result = None
+ }
+
+ override def execute(session: SparkSession): Unit = {
+ try {
+ val rows = Some(Dataset.ofRows(session, parsedPlan).collect())
+ if (shouldCollectResult) {
+ result = rows
+ }
+ } catch {
+ case e: SparkThrowable =>
+ raisedError = true
+ errorState = Some(e.getSqlState)
+ error = Some(e)
+ e match {
+ case throwable: Throwable =>
+ rethrow = Some(throwable)
+ case _ =>
+ }
+ case throwable: Throwable =>
+ raisedError = true
+ errorState = Some("SQLEXCEPTION")
+ rethrow = Some(throwable)
+ }
+ }
}
/**
- * 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,
+ label: Option[String] = None,
Review Comment:
I'm thinking we probably shouldn't have labels as optional in the future -
it's either explicitly specified or implicitly set to something random. For
now, we don't have logical operator for `LEAVE`, so this means that in
`transform*` methods in the interpreter we should probably pass random string
for now and also not use `.getOrElse("")` part in `handleLeave()` since when we
introduce `LEAVE` statement to the grammar labels will be mandatory.
--
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]