davidm-db commented on code in PR #47423:
URL: https://github.com/apache/spark/pull/47423#discussion_r1713880294
##########
sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionNode.scala:
##########
@@ -127,20 +148,112 @@ class SingleStatementExec(
origin.sqlText.get.substring(origin.startIndex.get, origin.stopIndex.get +
1)
}
- override def reset(): Unit = isExecuted = false
+ override def reset(): Unit = {
+ raisedError = false
+ errorState = None
+ error = None
+ rethrow = None
+ result = None // Should we do this?
+ }
+
+ 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(
+ label: Option[String] = None,
+ statements: Seq[CompoundStatementExec],
+ conditionHandlerMap: mutable.HashMap[String, ErrorHandlerExec] =
mutable.HashMap(),
+ session: SparkSession)
extends NonLeafStatementExec {
- private var localIterator = collection.iterator
- private var curr = if (localIterator.hasNext) Some(localIterator.next())
else None
+ private def getHandler(condition: String): Option[ErrorHandlerExec] = {
+ conditionHandlerMap.get(condition)
+ .orElse(conditionHandlerMap.get("NOT FOUND") match {
+ case Some(handler) if condition.startsWith("02") => Some(handler)
Review Comment:
nit: maybe add a small comment that explains "02" logic
--
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]