davidm-db commented on code in PR #49427:
URL: https://github.com/apache/spark/pull/49427#discussion_r1916408495
##########
sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecution.scala:
##########
@@ -97,18 +101,52 @@ class SqlScriptingExecution(
None
}
- private def handleException(e: Throwable): Unit = {
- // Rethrow the exception.
- // TODO: SPARK-48353 Add error handling for SQL scripts
- throw e
+ /**
+ * Advances through the script and executes statements until a result
statement or
+ * end of script is encountered.
+ *
+ * To know if there is result statement available, the method has to advance
through script and
+ * execute statements until the result statement or end of script is
encountered. For that reason
+ * the returned result must be executed before subsequent calls. Multiple
calls without executing
+ * the intermediate results will lead to incorrect behavior.
+ *
+ * @return Result DataFrame if it is available, otherwise None.
+ */
+ def getNextResult: Option[DataFrame] = {
+ try {
+ getNextResultInternal
+ } catch {
+ case e: SparkThrowable =>
+ handleException(e)
+ getNextResult // After handling the exception, try to get the next
result again.
Review Comment:
nit: wouldn't say "after handling the exception" since it's not actually
handled, it's more like setup for exception handling.
--
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]