dusantism-db commented on code in PR #48794:
URL: https://github.com/apache/spark/pull/48794#discussion_r1834332113


##########
sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingInterpreter.scala:
##########
@@ -124,6 +124,22 @@ case class SqlScriptingInterpreter() {
         val bodyExec = transformTreeIntoExecutable(body, 
session).asInstanceOf[CompoundBodyExec]
         new LoopStatementExec(bodyExec, label)
 
+      case ForStatement(query, variableNameOpt, body, label) =>
+        val queryExec = new SingleStatementExec(query.parsedPlan, 
query.origin, isInternal = false)
+        val bodyExec =
+          transformTreeIntoExecutable(body, 
session).asInstanceOf[CompoundBodyExec]
+        val finalExec = variableNameOpt match {
+          case None => bodyExec
+          case Some(variableName) =>
+            val dropVariableExec = new SingleStatementExec(
+              DropVariable(UnresolvedIdentifier(Seq(variableName)), ifExists = 
true),
+              Origin(),
+              isInternal = true
+            )
+            new CompoundBodyExec(Seq(bodyExec, dropVariableExec))

Review Comment:
   Sure, will change. For some reason i thought we did it like this for 
compounds.



-- 
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]

Reply via email to