This is an automated email from the ASF dual-hosted git repository.

dongjoon-hyun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a33153f6203 [SPARK-60973][SQL] Remove unused 
`VariableAssignmentUtils` from `sql/core`
9a33153f6203 is described below

commit 9a33153f62032f49fa59871d4f490b2c1c04cb24
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Thu Nov 5 20:26:20 2026 -0800

    [SPARK-60973][SQL] Remove unused `VariableAssignmentUtils` from `sql/core`
    
    ### What changes were proposed in this pull request?
    
    This PR aims to remove the unused 
`org.apache.spark.sql.execution.command.v2.VariableAssignmentUtils` object (and 
its only method `assignVariable`) from `sql/core`.
    
    Note that this is a different file from 
`org.apache.spark.sql.catalyst.analysis.VariableAssignmentUtils` in 
`sql/catalyst`, which is used by `ResolveSetVariable` and `ResolveFetchCursor` 
and is left untouched.
    
    ### Why are the changes needed?
    
    `assignVariable` has had no caller since it was introduced:
    
    - It was added as a new file by SPARK-54759 (SQL scripting Cursor support, 
`7783f46f58f`, 2026-01-28), first released in 
[v4.2.0](https://github.com/apache/spark/releases/tag/v4.2.0) (2026-07-11). 
Even at that commit, the definition was the only occurrence in the repository.
    - Its comment says it is shared by SET and FETCH, but neither command uses 
it.
    - SPARK-55891 (`fa872498ed6`, 2026-03-11) and SPARK-56681 (`3a3e4edb02d`, 
2026-05-04) modified the file, but no caller was added.
    - The shared helper role is now played by `VariableAssignmentUtils` in 
`sql/catalyst`, introduced by SPARK-60614 (`fd194c2d7dd`, 2026-10-29).
    
    Removing the dead code reduces the maintenance burden and the confusion 
caused by two objects with the same name.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. This is an internal object and nothing references it.
    
    ### How was this patch tested?
    
    Pass the CIs. Also verified locally:
    
    ```
    build/sbt -Phive sql/Test/compile
    build/sbt -Phive sql/scalastyle
    ```
    
    and confirmed with `git grep` that nothing references `assignVariable` or 
`command.v2.VariableAssignmentUtils`.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Sonnet 5.5
    
    Closes #60153 from dongjoon-hyun/SPARK-60973.
    
    Authored-by: Dongjoon Hyun <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 .../command/v2/VariableAssignmentUtils.scala       | 87 ----------------------
 1 file changed, 87 deletions(-)

diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/v2/VariableAssignmentUtils.scala
 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/v2/VariableAssignmentUtils.scala
deleted file mode 100644
index d99ddae538a6..000000000000
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/v2/VariableAssignmentUtils.scala
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.spark.sql.execution.command.v2
-
-import java.util.Locale
-
-import org.apache.spark.SparkException
-import org.apache.spark.sql.catalyst.SqlScriptingContextManager
-import org.apache.spark.sql.catalyst.analysis.{FakeLocalCatalog, 
FakeSystemCatalog}
-import org.apache.spark.sql.catalyst.catalog.{VariableDefinition, 
VariableManager}
-import org.apache.spark.sql.catalyst.expressions.{Literal, VariableReference}
-import 
org.apache.spark.sql.errors.QueryCompilationErrors.unresolvedVariableError
-import org.apache.spark.sql.internal.SQLConf
-
-/**
- * Utility methods for variable assignment shared between SET and FETCH 
commands.
- */
-object VariableAssignmentUtils {
-
-  /**
-   * Assigns a value to a variable (either scripting local or session).
-   * Uses the variable's catalog to determine which variable manager to use:
-   * - FakeLocalCatalog: scripting local variables (managed by 
SqlScriptingContextManager)
-   * - FakeSystemCatalog: session variables (managed by TempVariableManager)
-   *
-   * @param varRef The variable reference containing catalog information
-   * @param value The value to assign
-   * @param tempVariableManager The session-level variable manager
-   * @param conf SQL configuration for case sensitivity
-   */
-  def assignVariable(
-      varRef: VariableReference,
-      value: Any,
-      tempVariableManager: VariableManager,
-      conf: SQLConf): Unit = {
-    val namePartsCaseAdjusted = if (conf.caseSensitiveAnalysis) {
-      varRef.originalNameParts
-    } else {
-      varRef.originalNameParts.map(_.toLowerCase(Locale.ROOT))
-    }
-
-    val scriptingVariableManager = 
SqlScriptingContextManager.get().flatMap(_.getVariableManager)
-
-    val variableManager = varRef.catalog match {
-      case FakeLocalCatalog if scriptingVariableManager.isEmpty =>
-        throw SparkException.internalError("Variable has FakeLocalCatalog, " +
-          "but ScriptingVariableManager is None.")
-
-      case FakeLocalCatalog if 
scriptingVariableManager.get.get(namePartsCaseAdjusted).isEmpty =>
-        throw SparkException.internalError("Local variable should be present " 
+
-          "because variable resolution has already determined it exists.")
-
-      case FakeLocalCatalog => scriptingVariableManager.get
-
-      case FakeSystemCatalog if 
tempVariableManager.get(namePartsCaseAdjusted).isEmpty =>
-        throw unresolvedVariableError(
-          namePartsCaseAdjusted, Seq(Seq("SYSTEM", "SESSION")), varRef.origin)
-
-      case FakeSystemCatalog => tempVariableManager
-
-      case c => throw SparkException.internalError("Unexpected catalog: " + c)
-    }
-
-    val varDef = VariableDefinition(
-      varRef.identifier,
-      varRef.varDef.defaultValueSQL,
-      Literal(value, varRef.dataType)
-    )
-
-    variableManager.set(namePartsCaseAdjusted, varDef, varRef.origin)
-  }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to