diff --git a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala index afd6d45ed444..5c94dec6feb3 100644 --- a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala +++ b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala @@ -27,7 +27,7 @@ import org.apache.hive.service.cli.thrift.{ThriftBinaryCLIService, ThriftHttpCLI import org.apache.hive.service.server.HiveServer2 import org.apache.spark.SparkContext -import org.apache.spark.annotation.DeveloperApi +import org.apache.spark.annotation.{DeveloperApi, Since} import org.apache.spark.internal.Logging import org.apache.spark.internal.config.UI.UI_ENABLED import org.apache.spark.sql.SQLContext @@ -56,8 +56,9 @@ object HiveThriftServer2 extends Logging { * the call logs the error and exits the JVM with exit code -1. When false, the * call throws an exception instead. */ + @Since("3.5.2") @DeveloperApi - def startWithContext(sqlContext: SQLContext, exitOnError: Boolean = true): HiveThriftServer2 = { + def startWithContext(sqlContext: SQLContext, exitOnError: Boolean): HiveThriftServer2 = { systemExitOnError.set(exitOnError) val executionHive = HiveUtils.newClientForExecution( @@ -75,6 +76,18 @@ object HiveThriftServer2 extends Logging { server } + /** + * :: DeveloperApi :: + * Starts a new thrift server with the given context. + * + * @param sqlContext SQLContext to use for the server + */ + @Since("2.0.0") + @DeveloperApi + def startWithContext(sqlContext: SQLContext): HiveThriftServer2 = { + startWithContext(sqlContext, exitOnError = true) + } + private def createListenerAndUI(server: HiveThriftServer2, sc: SparkContext): Unit = { val kvStore = sc.statusStore.store.asInstanceOf[ElementTrackingStore] eventManager = new HiveThriftServer2EventManager(sc)