davidm-db commented on code in PR #48794:
URL: https://github.com/apache/spark/pull/48794#discussion_r1834167674
##########
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:
can't we just append `dropVariableExec` to the `collection` within
`bodyExec`?
current approach seems like unnecessary nesting, which we should avoid if
possible.
it would also make it equivalent to what we are doing for regular 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]