cloud-fan commented on code in PR #47609:
URL: https://github.com/apache/spark/pull/47609#discussion_r1718507613
##########
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] = {
+ val resultsIter = executeInternal(compoundBody)
+ resultsIter.foldLeft(Array.empty[Row])((_, next) => next).toSeq
Review Comment:
do we just want to get the last item? Does `resultIterator.last` work?
--
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]