Github user hvanhovell commented on a diff in the pull request: https://github.com/apache/spark/pull/16233#discussion_r94632509 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala --- @@ -50,6 +50,35 @@ object SimpleAnalyzer extends Analyzer( new SimpleCatalystConf(caseSensitiveAnalysis = true)) /** + * Provides a location for Analyzer to ask about the context of current resolution, this enables + * us to decouple the concerns of analysis environment from the catalog. + * + * @param defaultDatabase The default database used in the view resolution, this has a higher + * priority than the `currentDb` in the catalog. + * @param nestedViewLevel The nested level in the view resolution, this enables us to limit the + * depth of nested views. + */ +case class AnalysisContext( + defaultDatabase: Option[String] = None, + nestedViewLevel: Int = 0) + +object AnalysisContext { + private val value = new ThreadLocal[AnalysisContext]() { + override def initialValue: AnalysisContext = AnalysisContext() + } + + def get: AnalysisContext = value.get() + def set(context: AnalysisContext): Unit = value.set(context) + + def withAnalysisContext[A](context: AnalysisContext)(f: => A): A = { + val originContext = value.get() + set(context) + val ret = try f finally { set(originContext) } --- End diff -- why do we need the val?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org