Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ private[hive] class SparkExecuteStatementOperation(

// User information is part of the metastore client member in Hive
hiveContext.setSession(currentSqlSession)
// Always use the latest class loader provided by executionHive's state.
val executionHiveClassLoader =
hiveContext.executionHive.state.getConf.getClassLoader
sessionHive.getConf.setClassLoader(executionHiveClassLoader)
parentSessionState.getConf.setClassLoader(executionHiveClassLoader)

Hive.set(sessionHive)
SessionState.setCurrentSessionState(parentSessionState)
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,60 @@ class HiveThriftBinaryServerSuite extends HiveThriftJdbcTest {
rs2.close()
}
}

test("test add jar") {
withMultipleConnectionJdbcStatement(
{
statement =>
val jarFile =
"../hive/src/test/resources/hive-hcatalog-core-0.13.1.jar"
.split("/")
.mkString(File.separator)

statement.executeQuery(s"ADD JAR $jarFile")
},

{
statement =>
val queries = Seq(
"DROP TABLE IF EXISTS smallKV",
"CREATE TABLE smallKV(key INT, val STRING)",
s"LOAD DATA LOCAL INPATH '${TestData.smallKv}' OVERWRITE INTO TABLE smallKV",
"DROP TABLE IF EXISTS addJar",
"""CREATE TABLE addJar(key string)
|ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
""".stripMargin)

queries.foreach(statement.execute)

statement.executeQuery(
"""
|INSERT INTO TABLE addJar SELECT 'k1' as key FROM smallKV limit 1
""".stripMargin)

val actualResult =
statement.executeQuery("SELECT key FROM addJar")
val actualResultBuffer = new collection.mutable.ArrayBuffer[String]()
while (actualResult.next()) {
actualResultBuffer += actualResult.getString(1)
}
actualResult.close()

val expectedResult =
statement.executeQuery("SELECT 'k1'")
val expectedResultBuffer = new collection.mutable.ArrayBuffer[String]()
while (expectedResult.next()) {
expectedResultBuffer += expectedResult.getString(1)
}
expectedResult.close()

assert(expectedResultBuffer === actualResultBuffer)

statement.executeQuery("DROP TABLE IF EXISTS addJar")
statement.executeQuery("DROP TABLE IF EXISTS smallKV")
}
)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liancheng is this test good?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this LGTM.

}

class HiveThriftHttpServerSuite extends HiveThriftJdbcTest {
Expand Down