[KYUUBI #1056] [BUG] Log error if no current spark sql engine is created.

Issue:  https://github.com/apache/incubator-kyuubi/issues/1056

### _Why are the changes needed?_
Log an error message if no current spark sql engine is created.

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #1423 from jadireddi/1056-no-currEng.

Closes #1056

a8d0443d [Jagadesh Adireddi] refactor
565d41a4 [Jagadesh Adireddi] [KYUUBI #1056] [BUG] Log error if no current spark sql engine is created.

Authored-by: Jagadesh Adireddi <jadiredd@conviva.com>
Signed-off-by: fwang12 <fwang12@ebay.com>
This commit is contained in:
Jagadesh Adireddi 2021-11-20 12:16:55 +08:00 committed by fwang12
parent fda295865e
commit 15844dc373

View File

@ -158,12 +158,15 @@ object SparkSQLEngine extends Logging {
// blocking main thread
countDownLatch.await()
} catch {
case e: KyuubiException if currentEngine.isDefined =>
val engine = currentEngine.get
engine.stop()
val event = EngineEvent(engine).copy(diagnostic = e.getMessage)
EventLoggingService.onEvent(event)
error(event, e)
case e: KyuubiException => currentEngine match {
case Some(engine) =>
engine.stop()
val event = EngineEvent(engine).copy(diagnostic = e.getMessage)
EventLoggingService.onEvent(event)
error(event, e)
case _ => error("Current SparkSQLEngine is not created.")
}
}
} catch {
case t: Throwable => error(s"Failed to instantiate SparkSession: ${t.getMessage}", t)