From ce3147fad83ac1540ba3c8fd06ed2e624caa3400 Mon Sep 17 00:00:00 2001 From: Min Zhao Date: Mon, 5 Jul 2021 13:25:10 +0800 Subject: [PATCH] [KYUUBI #728] Support SQL State: 0A000 - feature_not_supported ### _Why are the changes needed?_ Follow #670 to: Apply errorCode 0A000: feature_not_supported to val errStatus = KyuubiSQLException("Feature is not available").toTStatus ### _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 - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/tools/testing.html#running-tests) locally before make a pull request Closes #729 from zhaomin1423/728. Closes #728 396e70d8 [Min Zhao] update FrontendServiceSuite to adapt KyuubiSQLException.featureNotSupported c06dbfd2 [Min Zhao] invoke KyuubiSQLException.featureNotSupported() in FrontendService 281aed97 [Min Zhao] add featureNotSupported to KyuubiSQLException object Authored-by: Min Zhao Signed-off-by: ulysses-you --- .../main/scala/org/apache/kyuubi/KyuubiSQLException.scala | 4 ++++ .../scala/org/apache/kyuubi/service/FrontendService.scala | 4 ++-- .../org/apache/kyuubi/service/FrontendServiceSuite.scala | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) 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") } }