Skip to content

Commit

Permalink
Hive engine compatiable with Hive 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
pan3793 committed Nov 23, 2023
1 parent fcd80c4 commit 13eb76d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 27 deletions.
30 changes: 12 additions & 18 deletions externals/kyuubi-hive-sql-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-service-rpc</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libfb303</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
Expand All @@ -73,12 +61,6 @@
<artifactId>commons-collections</artifactId>
</dependency>

<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>failureaccess</artifactId>
Expand Down Expand Up @@ -206,6 +188,18 @@
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.fasterxml.jackson</pattern>
<shadedPattern>${kyuubi.shade.packageName}.com.fasterxml.jackson</shadedPattern>
<includes>
<include>com.fasterxml.jackson.**</include>
</includes>
</relocation>
</relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"></transformer>
</transformers>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.kyuubi.engine.hive.session

import java.io.File
import java.util.{List => JList}
import java.util.concurrent.Future

import scala.collection.JavaConverters._
Expand All @@ -34,6 +35,7 @@ import org.apache.kyuubi.engine.hive.HiveSQLEngine
import org.apache.kyuubi.engine.hive.operation.HiveOperationManager
import org.apache.kyuubi.operation.OperationManager
import org.apache.kyuubi.session.{Session, SessionHandle, SessionManager}
import org.apache.kyuubi.util.reflect.DynConstructors

class HiveSessionManager(engine: HiveSQLEngine) extends SessionManager("HiveSessionManager") {
override protected def isServer: Boolean = false
Expand Down Expand Up @@ -78,15 +80,37 @@ class HiveSessionManager(engine: HiveSQLEngine) extends SessionManager("HiveSess
val sessionHandle =
conf.get(KYUUBI_SESSION_HANDLE_KEY).map(SessionHandle.fromUUID).getOrElse(SessionHandle())
val hive = {
val sessionWithUGI = new ImportedHiveSessionImpl(
new ImportedSessionHandle(sessionHandle.toTSessionHandle, protocol),
protocol,
user,
password,
HiveSQLEngine.hiveConf,
ipAddress,
null,
Seq(ipAddress).asJava)

val sessionWithUGI = DynConstructors.builder()
.impl( // for Hive 3.1
classOf[ImportedHiveSessionImpl],
classOf[ImportedSessionHandle],
classOf[TProtocolVersion],
classOf[String],
classOf[String],
classOf[HiveConf],
classOf[String],
classOf[String],
classOf[JList[String]])
.impl( // for Hive 2.3
classOf[ImportedHiveSessionImpl],
classOf[ImportedSessionHandle],
classOf[TProtocolVersion],
classOf[String],
classOf[String],
classOf[HiveConf],
classOf[String],
classOf[String])
.build[ImportedHiveSessionImpl]()
.newInstance(
new ImportedSessionHandle(sessionHandle.toTSessionHandle, protocol),
protocol,
user,
password,
HiveSQLEngine.hiveConf,
ipAddress,
null,
Seq(ipAddress).asJava)
val proxy = HiveSessionProxy.getProxy(sessionWithUGI, sessionWithUGI.getSessionUgi)
sessionWithUGI.setProxySession(proxy)
proxy
Expand Down

0 comments on commit 13eb76d

Please sign in to comment.