dusantism-db commented on code in PR #49445: URL: https://github.com/apache/spark/pull/49445#discussion_r1946873936
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveCatalogs.scala: ########## @@ -73,28 +95,49 @@ class ResolveCatalogs(val catalogManager: CatalogManager) } } - private def resolveVariableName(nameParts: Seq[String]): ResolvedIdentifier = { - def ident: Identifier = Identifier.of(Array(CatalogManager.SESSION_NAMESPACE), nameParts.last) - if (nameParts.length == 1) { - ResolvedIdentifier(FakeSystemCatalog, ident) - } else if (nameParts.length == 2) { - if (nameParts.head.equalsIgnoreCase(CatalogManager.SESSION_NAMESPACE)) { - ResolvedIdentifier(FakeSystemCatalog, ident) - } else { - throw QueryCompilationErrors.unresolvedVariableError( - nameParts, Seq(CatalogManager.SYSTEM_CATALOG_NAME, CatalogManager.SESSION_NAMESPACE)) - } - } else if (nameParts.length == 3) { - if (nameParts(0).equalsIgnoreCase(CatalogManager.SYSTEM_CATALOG_NAME) && - nameParts(1).equalsIgnoreCase(CatalogManager.SESSION_NAMESPACE)) { - ResolvedIdentifier(FakeSystemCatalog, ident) - } else { - throw QueryCompilationErrors.unresolvedVariableError( - nameParts, Seq(CatalogManager.SYSTEM_CATALOG_NAME, CatalogManager.SESSION_NAMESPACE)) - } - } else { + private def resolveCreateVariableName(nameParts: Seq[String]): ResolvedIdentifier = { + val resolvedIdentifier = SqlScriptingLocalVariableManager.get() + .filterNot(_ => AnalysisContext.get.isExecuteImmediate) + .getOrElse(catalogManager.tempVariableManager) + .resolveIdentifier(nameParts.last) Review Comment: Another note, in this iteration of local variables creating session variables directly from scripts is not posssible, per offline agreement with @srielau . It can only be done from EXECUTE IMMEDIATE. This is due to some grammar issues we need to figure out, once we do the support will be added in a followup PR. -- 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