Skip to content

Commit 584c7f1

Browse files
committed
[SPARK-21699][SQL] Remove unused getTableOption in ExternalCatalog
## What changes were proposed in this pull request? This patch removes the unused SessionCatalog.getTableMetadataOption and ExternalCatalog. getTableOption. ## How was this patch tested? Removed the test case. Author: Reynold Xin <[email protected]> Closes apache#18912 from rxin/remove-getTableOption.
1 parent ca69558 commit 584c7f1

File tree

5 files changed

+3
-35
lines changed

5 files changed

+3
-35
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/ExternalCatalog.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ abstract class ExternalCatalog
167167

168168
def getTable(db: String, table: String): CatalogTable
169169

170-
def getTableOption(db: String, table: String): Option[CatalogTable]
171-
172170
def tableExists(db: String, table: String): Boolean
173171

174172
def listTables(db: String): Seq[String]

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,6 @@ class InMemoryCatalog(
326326
catalog(db).tables(table).table
327327
}
328328

329-
override def getTableOption(db: String, table: String): Option[CatalogTable] = synchronized {
330-
if (!tableExists(db, table)) None else Option(catalog(db).tables(table).table)
331-
}
332-
333329
override def tableExists(db: String, table: String): Boolean = synchronized {
334330
requireDbExists(db)
335331
catalog(db).tables.contains(table)

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,10 @@ class SessionCatalog(
387387

388388
/**
389389
* Retrieve the metadata of an existing permanent table/view. If no database is specified,
390-
* assume the table/view is in the current database. If the specified table/view is not found
391-
* in the database then a [[NoSuchTableException]] is thrown.
390+
* assume the table/view is in the current database.
392391
*/
392+
@throws[NoSuchDatabaseException]
393+
@throws[NoSuchTableException]
393394
def getTableMetadata(name: TableIdentifier): CatalogTable = {
394395
val db = formatDatabaseName(name.database.getOrElse(getCurrentDatabase))
395396
val table = formatTableName(name.table)
@@ -398,18 +399,6 @@ class SessionCatalog(
398399
externalCatalog.getTable(db, table)
399400
}
400401

401-
/**
402-
* Retrieve the metadata of an existing metastore table.
403-
* If no database is specified, assume the table is in the current database.
404-
* If the specified table is not found in the database then return None if it doesn't exist.
405-
*/
406-
def getTableMetadataOption(name: TableIdentifier): Option[CatalogTable] = {
407-
val db = formatDatabaseName(name.database.getOrElse(getCurrentDatabase))
408-
val table = formatTableName(name.table)
409-
requireDbExists(db)
410-
externalCatalog.getTableOption(db, table)
411-
}
412-
413402
/**
414403
* Load files stored in given path into an existing metastore table.
415404
* If no database is specified, assume the table is in the current database.

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,6 @@ abstract class SessionCatalogSuite extends AnalysisTest {
510510
}
511511
}
512512

513-
test("get option of table metadata") {
514-
withBasicCatalog { catalog =>
515-
assert(catalog.getTableMetadataOption(TableIdentifier("tbl1", Some("db2")))
516-
== Option(catalog.externalCatalog.getTable("db2", "tbl1")))
517-
assert(catalog.getTableMetadataOption(TableIdentifier("unknown_table", Some("db2"))).isEmpty)
518-
intercept[NoSuchDatabaseException] {
519-
catalog.getTableMetadataOption(TableIdentifier("tbl1", Some("unknown_db")))
520-
}
521-
}
522-
}
523-
524513
test("lookup table relation") {
525514
withBasicCatalog { catalog =>
526515
val tempTable1 = Range(1, 10, 1, 10)

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,6 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, hadoopConf: Configurat
669669
restoreTableMetadata(getRawTable(db, table))
670670
}
671671

672-
override def getTableOption(db: String, table: String): Option[CatalogTable] = withClient {
673-
client.getTableOption(db, table).map(restoreTableMetadata)
674-
}
675-
676672
/**
677673
* Restores table metadata from the table properties. This method is kind of a opposite version
678674
* of [[createTable]].

0 commit comments

Comments
 (0)