diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/KyuubiSQLException.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/KyuubiSQLException.scala index 324172a0c..77bfdbb84 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/KyuubiSQLException.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/KyuubiSQLException.scala @@ -81,6 +81,10 @@ object KyuubiSQLException { } } + def featureNotSupported(): KyuubiSQLException = { + KyuubiSQLException("feature not supported", sqlState = "0A000") + } + def toTStatus(e: Exception, verbose: Boolean = false): TStatus = e match { case k: KyuubiSQLException => k.toTStatus case _ => diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala index adba76504..7b56af6b6 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala @@ -389,7 +389,7 @@ class FrontendService private (name: String, be: BackendService, oomHook: Runnab override def GetPrimaryKeys(req: TGetPrimaryKeysReq): TGetPrimaryKeysResp = { debug(req.toString) val resp = new TGetPrimaryKeysResp - val errStatus = KyuubiSQLException("Feature is not available").toTStatus + val errStatus = KyuubiSQLException.featureNotSupported().toTStatus resp.setStatus(errStatus) resp } @@ -397,7 +397,7 @@ class FrontendService private (name: String, be: BackendService, oomHook: Runnab override def GetCrossReference(req: TGetCrossReferenceReq): TGetCrossReferenceResp = { debug(req.toString) val resp = new TGetCrossReferenceResp - val errStatus = KyuubiSQLException("Feature is not available").toTStatus + val errStatus = KyuubiSQLException.featureNotSupported().toTStatus resp.setStatus(errStatus) resp } diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/service/FrontendServiceSuite.scala b/kyuubi-common/src/test/scala/org/apache/kyuubi/service/FrontendServiceSuite.scala index a79598d9c..d8663cdb2 100644 --- a/kyuubi-common/src/test/scala/org/apache/kyuubi/service/FrontendServiceSuite.scala +++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/service/FrontendServiceSuite.scala @@ -326,8 +326,8 @@ class FrontendServiceSuite extends KyuubiFunSuite { val resp = client.GetPrimaryKeys(req) assert(resp.getOperationHandle === null) assert(resp.getStatus.getStatusCode === TStatusCode.ERROR_STATUS) - assert(resp.getStatus.getSqlState === null) - assert(resp.getStatus.getErrorMessage startsWith "Feature is not available") + assert(resp.getStatus.getSqlState === "0A000") + assert(resp.getStatus.getErrorMessage startsWith "feature not supported") } } @@ -338,8 +338,8 @@ class FrontendServiceSuite extends KyuubiFunSuite { val resp = client.GetCrossReference(req) assert(resp.getOperationHandle === null) assert(resp.getStatus.getStatusCode === TStatusCode.ERROR_STATUS) - assert(resp.getStatus.getSqlState === null) - assert(resp.getStatus.getErrorMessage startsWith "Feature is not available") + assert(resp.getStatus.getSqlState === "0A000") + assert(resp.getStatus.getErrorMessage startsWith "feature not supported") } }