diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/mysql/MySQLGenericPackets.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/mysql/MySQLGenericPackets.scala index f378bc0a09a..dcb603358cf 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/mysql/MySQLGenericPackets.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/mysql/MySQLGenericPackets.scala @@ -54,7 +54,8 @@ object MySQLErrPacket { case kse: KyuubiSQLException if kse.getCause != null => // prefer brief nested error message instead of whole stacktrace apply(kse.getCause) - case e: Exception if e.getMessage contains "NoSuchDatabaseException" => + case e: Exception + if (e.getMessage != null) && (e.getMessage contains "NoSuchDatabaseException") => MySQLErrPacket(1, MySQLErrorCode.ER_BAD_DB_ERROR, cause.getMessage) case se: SQLException if se.getSQLState == null => MySQLErrPacket(1, MySQLErrorCode.ER_INTERNAL_ERROR, cause.getMessage)