Skip to content

[SPARK-22487][SQL][Hive]Remove the unused HIVE_EXECUTION_VERSION property #19712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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 @@ -55,7 +55,6 @@ private[hive] object SparkSQLEnv extends Logging {
metadataHive.setOut(new PrintStream(System.out, true, "UTF-8"))
metadataHive.setInfo(new PrintStream(System.err, true, "UTF-8"))
metadataHive.setError(new PrintStream(System.err, true, "UTF-8"))
sparkSession.conf.set("spark.sql.hive.version", HiveUtils.hiveExecutionVersion)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ private[hive] class SparkSQLSessionManager(hiveServer: HiveServer2, sqlContext:
} else {
sqlContext.newSession()
}
ctx.setConf("spark.sql.hive.version", HiveUtils.hiveExecutionVersion)
if (sessionConf != null && sessionConf.containsKey("use:database")) {
ctx.sql(s"use ${sessionConf.get("use:database")}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ class HiveThriftBinaryServerSuite extends HiveThriftJdbcTest {

test("Checks Hive version") {
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery("SET spark.sql.hive.version")
val resultSet = statement.executeQuery("SET spark.sql.hive.metastore.version")
resultSet.next()
assert(resultSet.getString(1) === "spark.sql.hive.version")
assert(resultSet.getString(2) === HiveUtils.hiveExecutionVersion)
assert(resultSet.getString(1) === "spark.sql.hive.metastore.version")
assert(resultSet.getString(2) === HiveUtils.builtinHiveVersion)
}
}

Expand Down Expand Up @@ -521,20 +521,7 @@ class HiveThriftBinaryServerSuite extends HiveThriftJdbcTest {
conf += resultSet.getString(1) -> resultSet.getString(2)
}

assert(conf.get("spark.sql.hive.version") === Some("1.2.1"))
}
}

test("Checks Hive version via SET") {
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery("SET")

val conf = mutable.Map.empty[String, String]
while (resultSet.next()) {
conf += resultSet.getString(1) -> resultSet.getString(2)
}

assert(conf.get("spark.sql.hive.version") === Some("1.2.1"))
Copy link
Member

Choose a reason for hiding this comment

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

change it to spark.sql.hive.metastore.version?

Copy link
Member Author

Choose a reason for hiding this comment

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

this might need to set spark.sql.hive.metastore.version explicitly

Copy link
Member

Choose a reason for hiding this comment

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

Just make a try?

Copy link
Member Author

Choose a reason for hiding this comment

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

the first commit fails this ut checking spark.sql.hive.metastore.version. set cmd only shows the changed variables, if more unit tests are needed, i can add some.

assert(conf.get("spark.sql.hive.metastore.version") === Some("1.2.1"))
}
}

Expand Down Expand Up @@ -721,10 +708,10 @@ class HiveThriftHttpServerSuite extends HiveThriftJdbcTest {

test("Checks Hive version") {
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery("SET spark.sql.hive.version")
val resultSet = statement.executeQuery("SET spark.sql.hive.metastore.version")
resultSet.next()
assert(resultSet.getString(1) === "spark.sql.hive.version")
assert(resultSet.getString(2) === HiveUtils.hiveExecutionVersion)
assert(resultSet.getString(1) === "spark.sql.hive.metastore.version")
assert(resultSet.getString(2) === HiveUtils.builtinHiveVersion)
}
}
}
Expand Down
25 changes: 10 additions & 15 deletions sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,23 @@ private[spark] object HiveUtils extends Logging {
}

/** The version of hive used internally by Spark SQL. */
val hiveExecutionVersion: String = "1.2.1"
val builtinHiveVersion: String = "1.2.1"

val HIVE_METASTORE_VERSION = buildConf("spark.sql.hive.metastore.version")
.doc("Version of the Hive metastore. Available options are " +
s"<code>0.12.0</code> through <code>$hiveExecutionVersion</code>.")
s"<code>0.12.0</code> through <code>2.1.1</code>.")
.stringConf
.createWithDefault(hiveExecutionVersion)

val HIVE_EXECUTION_VERSION = buildConf("spark.sql.hive.version")
.doc("Version of Hive used internally by Spark SQL.")
.stringConf
.createWithDefault(hiveExecutionVersion)
.createWithDefault(builtinHiveVersion)

val HIVE_METASTORE_JARS = buildConf("spark.sql.hive.metastore.jars")
.doc(s"""
| Location of the jars that should be used to instantiate the HiveMetastoreClient.
| This property can be one of three options: "
| 1. "builtin"
| Use Hive ${hiveExecutionVersion}, which is bundled with the Spark assembly when
| Use Hive ${builtinHiveVersion}, which is bundled with the Spark assembly when
| <code>-Phive</code> is enabled. When this option is chosen,
| <code>spark.sql.hive.metastore.version</code> must be either
| <code>${hiveExecutionVersion}</code> or not defined.
| <code>${builtinHiveVersion}</code> or not defined.
| 2. "maven"
| Use Hive jars of specified version downloaded from Maven repositories.
| 3. A classpath in the standard format for both Hive and Hadoop.
Expand Down Expand Up @@ -259,9 +254,9 @@ private[spark] object HiveUtils extends Logging {
protected[hive] def newClientForExecution(
conf: SparkConf,
hadoopConf: Configuration): HiveClientImpl = {
logInfo(s"Initializing execution hive, version $hiveExecutionVersion")
logInfo(s"Initializing execution hive, version $builtinHiveVersion")
val loader = new IsolatedClientLoader(
version = IsolatedClientLoader.hiveVersion(hiveExecutionVersion),
version = IsolatedClientLoader.hiveVersion(builtinHiveVersion),
sparkConf = conf,
execJars = Seq.empty,
hadoopConf = hadoopConf,
Expand Down Expand Up @@ -297,12 +292,12 @@ private[spark] object HiveUtils extends Logging {
val metaVersion = IsolatedClientLoader.hiveVersion(hiveMetastoreVersion)

val isolatedLoader = if (hiveMetastoreJars == "builtin") {
if (hiveExecutionVersion != hiveMetastoreVersion) {
if (builtinHiveVersion != hiveMetastoreVersion) {
throw new IllegalArgumentException(
"Builtin jars can only be used when hive execution version == hive metastore version. " +
s"Execution: $hiveExecutionVersion != Metastore: $hiveMetastoreVersion. " +
s"Execution: $builtinHiveVersion != Metastore: $hiveMetastoreVersion. " +
"Specify a vaild path to the correct hive jars using $HIVE_METASTORE_JARS " +
s"or change ${HIVE_METASTORE_VERSION.key} to $hiveExecutionVersion.")
s"or change ${HIVE_METASTORE_VERSION.key} to $builtinHiveVersion.")
}

// We recursively find all jars in the class loader chain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ class VersionsSuite extends SparkFunSuite with Logging {
}

test("success sanity check") {
val badClient = buildClient(HiveUtils.hiveExecutionVersion, new Configuration())
val badClient = buildClient(HiveUtils.builtinHiveVersion, new Configuration())
val db = new CatalogDatabase("default", "desc", new URI("loc"), Map())
badClient.createDatabase(db, ignoreIfExists = true)
}

test("hadoop configuration preserved") {
val hadoopConf = new Configuration()
hadoopConf.set("test", "success")
val client = buildClient(HiveUtils.hiveExecutionVersion, hadoopConf)
val client = buildClient(HiveUtils.builtinHiveVersion, hadoopConf)
assert("success" === client.getConf("test", null))
}

Expand Down