From 370bf658a840df4c764d0f2239ec1af7ade82176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Ti=C5=A1ma?= Date: Thu, 23 Jan 2025 12:02:46 +0100 Subject: [PATCH] renames --- .../main/scala/org/apache/spark/sql/SparkSession.scala | 2 +- .../spark/sql/scripting/SqlScriptingExecution.scala | 8 ++++---- .../spark/sql/scripting/SqlScriptingExecutionSuite.scala | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala b/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala index e4783d9ebb93c..227d901c2ce74 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala @@ -446,7 +446,7 @@ class SparkSession private( script: CompoundBody, args: Map[String, Expression] = Map.empty): DataFrame = { val sse = new SqlScriptingExecution(script, this, args) - sse.runWithContext { + sse.withVariableManager { var result: Option[Seq[Row]] = None // We must execute returned df before calling sse.getNextResult again because sse.hasNext diff --git a/sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecution.scala b/sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecution.scala index d32934b4506aa..6b2d5389e7fc5 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecution.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecution.scala @@ -26,7 +26,7 @@ import org.apache.spark.sql.catalyst.plans.logical.{CommandResult, CompoundBody} * SQL scripting executor - executes script and returns result statements. * This supports returning multiple result statements from a single script. * The caller of the SqlScriptingExecution API must wrap the interpretation and execution of - * statements with the [[runWithContext]] method, and adhere to the contract of executing + * statements with the [[withVariableManager]] method, and adhere to the contract of executing * the returned statement before continuing iteration. Executing the statement needs to be done * inside withErrorHandling block. * @@ -55,14 +55,14 @@ class SqlScriptingExecution( } private val variableManager = new SqlScriptingVariableManager(context) - private val handle = SqlScriptingVariableManager.create(variableManager) + private val variableManagerHandle = SqlScriptingVariableManager.create(variableManager) /** * Handles scripting context creation/access/deletion. Calls to execution API must be wrapped * with this method. */ - def runWithContext[R](f: => R): R = { - handle.runWith(f) + def withVariableManager[R](f: => R): R = { + variableManagerHandle.runWith(f) } /** Helper method to iterate get next statements from the first available frame. */ diff --git a/sql/core/src/test/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionSuite.scala index 00dd77f2543c6..b4491cfb8edf2 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionSuite.scala @@ -47,7 +47,7 @@ class SqlScriptingExecutionSuite extends QueryTest with SharedSparkSession { val compoundBody = spark.sessionState.sqlParser.parsePlan(sqlText).asInstanceOf[CompoundBody] val sse = new SqlScriptingExecution(compoundBody, spark, args) - sse.runWithContext { + sse.withVariableManager { val result: ListBuffer[Array[Row]] = ListBuffer.empty var df = sse.getNextResult