dusantism-db commented on code in PR #49445:
URL: https://github.com/apache/spark/pull/49445#discussion_r1944679337
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ColumnResolutionHelper.scala:
##########
@@ -266,22 +275,46 @@ 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))
+ }
+
+ SqlScriptingLocalVariableManager.get()
+ // If sessionOnly is set to true lookup only session variables.
+ .filterNot(_ => AnalysisContext.get.isExecuteImmediate)
+ // If variable name is qualified with system.session.<varName> treat it
as a session variable.
Review Comment:
I think it is fine to leave the explicit checks here, because it's more
performant this way as local variable lookup will iterate through all frames
and scopes. Also if we have it explicitly it will be safer if we make changes
in the future.
--
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]