miland-db commented on code in PR #47609:
URL: https://github.com/apache/spark/pull/47609#discussion_r1718515637


##########
sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingInterpreter.scala:
##########
@@ -17,32 +17,42 @@
 
 package org.apache.spark.sql.scripting
 
-import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.{Row, SparkSession}
 import org.apache.spark.sql.catalyst.analysis.UnresolvedIdentifier
-import org.apache.spark.sql.catalyst.parser.{CompoundBody, 
CompoundPlanStatement, IfElseStatement, SingleStatement, WhileStatement}
-import org.apache.spark.sql.catalyst.plans.logical.{CreateVariable, 
DropVariable, LogicalPlan}
+import org.apache.spark.sql.catalyst.plans.logical.{CompoundBody, 
CompoundPlanStatement, CreateVariable, DropVariable, IfElseStatement, 
LogicalPlan, SingleStatement, WhileStatement}
 import org.apache.spark.sql.catalyst.trees.Origin
 
 /**
  * SQL scripting interpreter - builds SQL script execution plan.
+ *
+ * @param session
+ *   Spark session that SQL script is executed within.
  */
-case class SqlScriptingInterpreter() {
+case class SqlScriptingInterpreter(session: SparkSession) {
+
+  /**
+   * Execute the provided CompoundBody and return the result.
+   *
+   * @param compoundBody
+   *   CompoundBody to execute.
+   * @return Result of the execution.
+   */
+  def execute(compoundBody: CompoundBody): Seq[Row] = {

Review Comment:
   The idea for execute is to return only the last `DataFrame`. We can also 
wrap it here in `LocalRelation`, but we decided to do it in the same place 
where `DataFrame` was created before -> in `SparkSession`.



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