From 9fbe1ac97f2e03f913545238c8adabe0824fd432 Mon Sep 17 00:00:00 2001 From: senmiaoliu Date: Fri, 1 Nov 2024 10:08:08 +0800 Subject: [PATCH] add isHive21OrLower method --- .../org/apache/kyuubi/operation/AbstractOperation.scala | 7 +++++-- .../org/apache/kyuubi/operation/ExecuteStatement.scala | 6 ++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/operation/AbstractOperation.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/operation/AbstractOperation.scala index 37dc08ecf20..3110b064125 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/operation/AbstractOperation.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/operation/AbstractOperation.scala @@ -69,8 +69,7 @@ abstract class AbstractOperation(session: Session) extends Operation with Loggin // this will cause the client of the lower version to get stuck. // Check thrift protocol version <= HIVE_CLI_SERVICE_PROTOCOL_V8(Hive 2.1.0), // convert TIMEDOUT_STATE to CANCELED. - if (getProtocolVersion.getValue <= - TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8.getValue) { + if (isHive21OrLower) { cleanup(OperationState.CANCELED) } else { cleanup(OperationState.TIMEOUT) @@ -287,4 +286,8 @@ abstract class AbstractOperation(session: Session) extends Operation with Loggin } } } + + protected def isHive21OrLower: Boolean = { + getProtocolVersion.getValue <= TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8.getValue + } } diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/ExecuteStatement.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/ExecuteStatement.scala index 026d4be2ddb..02c22e4f6a7 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/ExecuteStatement.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/ExecuteStatement.scala @@ -28,7 +28,7 @@ import org.apache.kyuubi.metrics.{MetricsConstants, MetricsSystem} import org.apache.kyuubi.operation.FetchOrientation.FETCH_NEXT import org.apache.kyuubi.operation.log.OperationLog import org.apache.kyuubi.session.Session -import org.apache.kyuubi.shaded.hive.service.rpc.thrift.{TGetOperationStatusResp, TOperationState, TProtocolVersion} +import org.apache.kyuubi.shaded.hive.service.rpc.thrift.{TGetOperationStatusResp, TOperationState} import org.apache.kyuubi.shaded.hive.service.rpc.thrift.TOperationState._ class ExecuteStatement( @@ -124,9 +124,7 @@ class ExecuteStatement( // this will cause the client of the lower version to get stuck. // Check thrift protocol version <= HIVE_CLI_SERVICE_PROTOCOL_V8(Hive 2.1.0), // convert TIMEDOUT_STATE to CANCELED. - if getProtocolVersion.getValue <= - TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8.getValue => - setState(OperationState.CANCELED) + if isHive21OrLower => setState(OperationState.CANCELED) case TIMEDOUT_STATE => setState(OperationState.TIMEOUT)