Repository: spark
Updated Branches:
  refs/heads/master 176ae4d53 -> f7534b37e


[SPARK-22487][SQL][FOLLOWUP] still keep spark.sql.hive.version

## What changes were proposed in this pull request?

a followup of https://github.com/apache/spark/pull/19712 , adds back the 
`spark.sql.hive.version`, so that if users try to read this config, they can 
still get a default value instead of null.

## How was this patch tested?

N/A

Author: Wenchen Fan <wenc...@databricks.com>

Closes #19719 from cloud-fan/minor.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/f7534b37
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/f7534b37
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/f7534b37

Branch: refs/heads/master
Commit: f7534b37ee91be14e511ab29259c3f83c7ad50af
Parents: 176ae4d
Author: Wenchen Fan <wenc...@databricks.com>
Authored: Mon Nov 13 13:10:13 2017 -0800
Committer: gatorsmile <gatorsm...@gmail.com>
Committed: Mon Nov 13 13:10:13 2017 -0800

----------------------------------------------------------------------
 .../sql/hive/thriftserver/SparkSQLEnv.scala     |  1 +
 .../thriftserver/SparkSQLSessionManager.scala   |  1 +
 .../thriftserver/HiveThriftServer2Suites.scala  | 23 +++++++++++++++-----
 .../org/apache/spark/sql/hive/HiveUtils.scala   |  8 +++++++
 4 files changed, 28 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/f7534b37/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLEnv.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLEnv.scala
 
b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLEnv.scala
index 5db93b2..6b19f97 100644
--- 
a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLEnv.scala
+++ 
b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLEnv.scala
@@ -55,6 +55,7 @@ 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(HiveUtils.FAKE_HIVE_VERSION.key, 
HiveUtils.builtinHiveVersion)
     }
   }
 

http://git-wip-us.apache.org/repos/asf/spark/blob/f7534b37/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLSessionManager.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLSessionManager.scala
 
b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLSessionManager.scala
index 00920c2..48c0ebe 100644
--- 
a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLSessionManager.scala
+++ 
b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLSessionManager.scala
@@ -77,6 +77,7 @@ private[hive] class SparkSQLSessionManager(hiveServer: 
HiveServer2, sqlContext:
     } else {
       sqlContext.newSession()
     }
+    ctx.setConf(HiveUtils.FAKE_HIVE_VERSION.key, HiveUtils.builtinHiveVersion)
     if (sessionConf != null && sessionConf.containsKey("use:database")) {
       ctx.sql(s"use ${sessionConf.get("use:database")}")
     }

http://git-wip-us.apache.org/repos/asf/spark/blob/f7534b37/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala
 
b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala
index b80596f..7289da7 100644
--- 
a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala
+++ 
b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala
@@ -155,9 +155,9 @@ class HiveThriftBinaryServerSuite extends 
HiveThriftJdbcTest {
 
   test("Checks Hive version") {
     withJdbcStatement() { statement =>
-      val resultSet = statement.executeQuery("SET 
spark.sql.hive.metastore.version")
+      val resultSet = statement.executeQuery("SET spark.sql.hive.version")
       resultSet.next()
-      assert(resultSet.getString(1) === "spark.sql.hive.metastore.version")
+      assert(resultSet.getString(1) === "spark.sql.hive.version")
       assert(resultSet.getString(2) === HiveUtils.builtinHiveVersion)
     }
   }
@@ -521,7 +521,20 @@ class HiveThriftBinaryServerSuite extends 
HiveThriftJdbcTest {
         conf += resultSet.getString(1) -> resultSet.getString(2)
       }
 
-      assert(conf.get("spark.sql.hive.metastore.version") === Some("1.2.1"))
+      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"))
     }
   }
 
@@ -708,9 +721,9 @@ class HiveThriftHttpServerSuite extends HiveThriftJdbcTest {
 
   test("Checks Hive version") {
     withJdbcStatement() { statement =>
-      val resultSet = statement.executeQuery("SET 
spark.sql.hive.metastore.version")
+      val resultSet = statement.executeQuery("SET spark.sql.hive.version")
       resultSet.next()
-      assert(resultSet.getString(1) === "spark.sql.hive.metastore.version")
+      assert(resultSet.getString(1) === "spark.sql.hive.version")
       assert(resultSet.getString(2) === HiveUtils.builtinHiveVersion)
     }
   }

http://git-wip-us.apache.org/repos/asf/spark/blob/f7534b37/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveUtils.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveUtils.scala 
b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveUtils.scala
index d8e08f1..f5e6720 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveUtils.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveUtils.scala
@@ -66,6 +66,14 @@ private[spark] object HiveUtils extends Logging {
     .stringConf
     .createWithDefault(builtinHiveVersion)
 
+  // A fake config which is only here for backward compatibility reasons. This 
config has no effect
+  // to Spark, just for reporting the builtin Hive version of Spark to 
existing applications that
+  // already rely on this config.
+  val FAKE_HIVE_VERSION = buildConf("spark.sql.hive.version")
+    .doc(s"deprecated, please use ${HIVE_METASTORE_VERSION.key} to get the 
Hive version in Spark.")
+    .stringConf
+    .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.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to