From 00b32a0381217130bc9b2c6da04f4f913fcba189 Mon Sep 17 00:00:00 2001 From: Cheng Pan Date: Thu, 1 Jun 2023 13:47:37 +0800 Subject: [PATCH] [KYUUBI #4915] Adapt database not exist error message change for Spark 3.4 ### _Why are the changes needed?_ Spark is migrating to the error class framework, in SPARK-40360(fixed in 3.4.0) SCHEMA_NOT_FOUND was introduced, which changes the output of the error message on switching a not existing database. ### _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/master/develop_tools/testing.html#running-tests) locally before make a pull request Closes #4915 from pan3793/schema-not-found. Closes #4915 c0e03feaf [Cheng Pan] nit 0ee0deada [Cheng Pan] SCHEMA_NOT_FOUND Authored-by: Cheng Pan Signed-off-by: Cheng Pan --- .../kyuubi/engine/spark/session/SparkSessionImpl.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala index 40a0c8c7f..39d02f067 100644 --- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala +++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala @@ -17,6 +17,7 @@ package org.apache.kyuubi.engine.spark.session +import org.apache.commons.lang3.StringUtils import org.apache.hive.service.rpc.thrift.{TGetInfoType, TGetInfoValue, TProtocolVersion} import org.apache.spark.sql.{AnalysisException, SparkSession} @@ -28,7 +29,7 @@ import org.apache.kyuubi.engine.spark.shim.SparkCatalogShim import org.apache.kyuubi.engine.spark.udf.KDFRegistry import org.apache.kyuubi.events.EventBus import org.apache.kyuubi.operation.{Operation, OperationHandle} -import org.apache.kyuubi.session.{AbstractSession, SessionHandle, SessionManager, USE_CATALOG, USE_DATABASE} +import org.apache.kyuubi.session._ class SparkSessionImpl( protocol: TProtocolVersion, @@ -73,8 +74,8 @@ class SparkSessionImpl( SparkCatalogShim().setCurrentDatabase(spark, database) } catch { case e - if database == "default" && e.getMessage != null && - e.getMessage.contains("not found") => + if database == "default" && + StringUtils.containsAny(e.getMessage, "not found", "SCHEMA_NOT_FOUND") => } }