Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -875,7 +875,7 @@ private[hive] class HiveClientImpl(
// Since HIVE-18238(Hive 3.0.0), the Driver.close function's return type changed
// and the CommandProcessorFactory.clean function removed.
driver.getClass.getMethod("close").invoke(driver)
if (version != hive.v3_0 && version != hive.v3_1 && version != hive.v4_0) {
if (version < hive.v3_0) {
CommandProcessorFactory.clean(conf)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.sql.hive

import org.apache.spark.util.Utils

/** Support for interacting with different versions of the HiveMetastoreClient */
package object client {
private[hive] sealed abstract class HiveVersion(
Expand Down Expand Up @@ -115,8 +117,14 @@ package object client {
exclusions =
"org.apache.curator:*" ::
"org.apache.hive:hive-service-rpc" ::
"org.apache.tez:tez-api" ::
"org.apache.zookeeper:zookeeper" :: Nil)
"org.apache.zookeeper:zookeeper" :: Nil ++
Copy link
Member

Choose a reason for hiding this comment

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

What's the root cause of this differentiation between test and other usage scopes?

Copy link
Member Author

@sarutak sarutak Dec 4, 2025

Choose a reason for hiding this comment

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

@yaooqinn
If the flow reaches here, the definition of Driver and referred classes by Driver including DriverContext are needed to be resolved.
Some members of DriverContext refer Tez related classes so tez-api dependency is necessary.
But in HiveClientImpl, Driver is used only in runHive and this method is used only for testing, so tez-api is needed only for testing too.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Can we add some explanatory comments here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. Added a comment.

{
if (!Utils.isTesting) {
Seq("org.apache.tez:tez-api")
} else {
Seq.empty
}
})

val allSupportedHiveVersions: Set[HiveVersion] =
Set(v2_0, v2_1, v2_2, v2_3, v3_0, v3_1, v4_0, v4_1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,13 @@ class HiveClientSuite(version: String) extends HiveVersionSuite(version) {
}
}

test("read table written by Hive") {
withTable("test_tbl") {
client.runSqlHive("CREATE TABLE test_tbl AS SELECT 1")
assert(versionSpark.sql("SELECT * from test_tbl").collect() === Array(Row(1)))
}
}

///////////////////////////////////////////////////////////////////////////
// Miscellaneous API
///////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ private[client] abstract class HiveVersionSuite(version: String) extends SparkFu
hadoopConf.set("datanucleus.autoStartMechanismMode", "ignored")
hadoopConf.set("hive.metastore.schema.verification", "false")
// Since Hive 3.0, HIVE-19310 skipped `ensureDbInit` if `hive.in.test=false`.
if (version == "3.0" || version == "3.1" || version == "4.0") {
val ver = IsolatedClientLoader.hiveVersion(version)
if (hive.v3_0 <= ver) {
hadoopConf.set("hive.in.test", "true")
hadoopConf.set("hive.query.reexecution.enabled", "false")
}
Expand Down