Repository: spark
Updated Branches:
  refs/heads/master 0f0d1865f -> d57a267b7


[SPARK-23259][SQL] Clean up legacy code around hive external catalog and 
HiveClientImpl

## What changes were proposed in this pull request?

Three legacy statements are removed by this patch:

- in HiveExternalCatalog: The withClient wrapper is not necessary for the 
private method getRawTable.

- in HiveClientImpl: There are some redundant code in both the tableExists and 
getTableOption method.

This PR takes over https://github.com/apache/spark/pull/20425

## How was this patch tested?

Existing tests

Closes #20425

Author: hyukjinkwon <[email protected]>

Closes #21780 from HyukjinKwon/SPARK-23259.


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

Branch: refs/heads/master
Commit: d57a267b79f4015508c3686c34a0f438bad41ea1
Parents: 0f0d186
Author: Feng Liu <[email protected]>
Authored: Tue Jul 17 09:13:35 2018 +0800
Committer: hyukjinkwon <[email protected]>
Committed: Tue Jul 17 09:13:35 2018 +0800

----------------------------------------------------------------------
 .../org/apache/spark/sql/hive/HiveExternalCatalog.scala      | 2 +-
 .../org/apache/spark/sql/hive/client/HiveClientImpl.scala    | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/d57a267b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala 
b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala
index 011a3ba..44480ce 100644
--- 
a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala
+++ 
b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala
@@ -114,7 +114,7 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, 
hadoopConf: Configurat
    * should interpret these special data source properties and restore the 
original table metadata
    * before returning it.
    */
-  private[hive] def getRawTable(db: String, table: String): CatalogTable = 
withClient {
+  private[hive] def getRawTable(db: String, table: String): CatalogTable = {
     client.getTable(db, table)
   }
 

http://git-wip-us.apache.org/repos/asf/spark/blob/d57a267b/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala 
b/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
index 1df46d7..db8fd5a 100644
--- 
a/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
+++ 
b/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
@@ -353,15 +353,19 @@ private[hive] class HiveClientImpl(
     client.getDatabasesByPattern(pattern).asScala
   }
 
+  private def getRawTableOption(dbName: String, tableName: String): 
Option[HiveTable] = {
+    Option(client.getTable(dbName, tableName, false /* do not throw exception 
*/))
+  }
+
   override def tableExists(dbName: String, tableName: String): Boolean = 
withHiveState {
-    Option(client.getTable(dbName, tableName, false /* do not throw exception 
*/)).nonEmpty
+    getRawTableOption(dbName, tableName).nonEmpty
   }
 
   override def getTableOption(
       dbName: String,
       tableName: String): Option[CatalogTable] = withHiveState {
     logDebug(s"Looking up $dbName.$tableName")
-    Option(client.getTable(dbName, tableName, false)).map { h =>
+    getRawTableOption(dbName, tableName).map { h =>
       // Note: Hive separates partition columns and the schema, but for us the
       // partition columns are part of the schema
       val cols = h.getCols.asScala.map(fromHiveColumn)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to