Github user kunalkhamar commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16826#discussion_r103307420
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionState.scala ---
    @@ -146,4 +107,153 @@ private[hive] class HiveSessionState(sparkSession: 
SparkSession)
         conf.getConf(HiveUtils.HIVE_THRIFT_SERVER_ASYNC)
       }
     
    +  /**
    +   * Get an identical copy of the `HiveSessionState`.
    +   * This should ideally reuse the `SessionState.clone` but cannot do so.
    +   * Doing that will throw an exception when trying to clone the catalog.
    +   */
    +  override def clone(newSparkSession: SparkSession): HiveSessionState = {
    +    val sparkContext = newSparkSession.sparkContext
    +    val confCopy = conf.clone()
    +    val functionRegistryCopy = functionRegistry.clone()
    +    val experimentalMethodsCopy = experimentalMethods.clone()
    +    val sqlParser: ParserInterface = new SparkSqlParser(confCopy)
    +    val catalogCopy = catalog.clone(
    +      newSparkSession,
    +      confCopy,
    +      SessionState.newHadoopConf(sparkContext.hadoopConfiguration, 
confCopy),
    +      functionRegistryCopy,
    +      sqlParser)
    +    val queryExecutionCreator = (plan: LogicalPlan) => new 
QueryExecution(newSparkSession, plan)
    +
    +    val hiveClient =
    +      
newSparkSession.sharedState.externalCatalog.asInstanceOf[HiveExternalCatalog].client
    +        .newSession()
    +
    +    SessionState.mergeSparkConf(confCopy, sparkContext.getConf)
    +
    +    new HiveSessionState(
    +      sparkContext,
    +      newSparkSession.sharedState,
    +      confCopy,
    +      experimentalMethodsCopy,
    +      functionRegistryCopy,
    +      catalogCopy,
    +      sqlParser,
    +      hiveClient,
    +      HiveSessionState.createAnalyzer(newSparkSession, catalogCopy, 
confCopy),
    +      new StreamingQueryManager(newSparkSession),
    +      queryExecutionCreator,
    +      HiveSessionState.createPlannerCreator(
    +        newSparkSession,
    +        confCopy,
    +        experimentalMethodsCopy))
    +  }
    +
    +}
    +
    +object HiveSessionState {
    +
    +  def apply(sparkSession: SparkSession): HiveSessionState = {
    +    apply(sparkSession, None)
    +  }
    +
    +  def apply(
    +      sparkSession: SparkSession,
    +      conf: Option[SQLConf]): HiveSessionState = {
    +
    +    val initHelper = SessionState(sparkSession, conf)
    +
    +    val sparkContext = sparkSession.sparkContext
    +
    +    val catalog = HiveSessionCatalog(
    +      sparkSession,
    +      SessionState.createFunctionResourceLoader(sparkContext, 
sparkSession.sharedState),
    +      initHelper.functionRegistry,
    +      initHelper.conf,
    +      SessionState.newHadoopConf(sparkContext.hadoopConfiguration, 
initHelper.conf),
    +      initHelper.sqlParser)
    +
    +    // A Hive client used for interacting with the metastore.
    +    val metadataHive: HiveClient =
    +      
sparkSession.sharedState.externalCatalog.asInstanceOf[HiveExternalCatalog].client
    +        .newSession()
    +
    +    // An analyzer that uses the Hive metastore.
    +    val analyzer: Analyzer = createAnalyzer(sparkSession, catalog, 
initHelper.conf)
    +
    +    val plannerCreator = createPlannerCreator(
    +      sparkSession,
    +      initHelper.conf,
    +      initHelper.experimentalMethods)
    +
    +    new HiveSessionState(
    +      sparkContext,
    +      sparkSession.sharedState,
    +      initHelper.conf,
    +      initHelper.experimentalMethods,
    +      initHelper.functionRegistry,
    +      catalog,
    +      initHelper.sqlParser,
    +      metadataHive,
    +      analyzer,
    +      initHelper.streamingQueryManager,
    +      initHelper.queryExecutionCreator,
    +      plannerCreator)
    +  }
    +
    +  def createAnalyzer(
    --- End diff --
    
    Yes!


---
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

Reply via email to