srielau commented on code in PR #49445:
URL: https://github.com/apache/spark/pull/49445#discussion_r1913455200


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ColumnResolutionHelper.scala:
##########
@@ -266,22 +268,40 @@ trait ColumnResolutionHelper extends Logging with 
DataTypeErrorsBase {
       }
     }
 
-    if (maybeTempVariableName(nameParts)) {
-      val variableName = if (conf.caseSensitiveAnalysis) {
-        nameParts.last
-      } else {
-        nameParts.last.toLowerCase(Locale.ROOT)
-      }
-      catalogManager.tempVariableManager.get(variableName).map { varDef =>
+    val namePartsCaseAdjusted = if (conf.caseSensitiveAnalysis) {
+      nameParts
+    } else {
+      nameParts.map(_.toLowerCase(Locale.ROOT))
+    }
+
+    catalogManager.scriptingLocalVariableManager
+      // If sessionOnly is set to true lookup only session variables.
+      .filterNot(_ => sessionVariablesOnly)
+      // If variable name is qualified with system.session.<varName> treat it 
as a session variable.
+      .filterNot(_ => nameParts.take(2).map(_.toLowerCase(Locale.ROOT)) == 
Seq("system", "session"))
+      // Local variable must be in format <varName> or <label>.<varName>
+      .filter(_ => namePartsCaseAdjusted.nonEmpty && 
namePartsCaseAdjusted.length <= 2)

Review Comment:
   Correct.



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to