Skip to content
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 @@ -167,8 +167,6 @@ abstract class ExternalCatalog

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

def getTableOption(db: String, table: String): Option[CatalogTable]

def tableExists(db: String, table: String): Boolean

def listTables(db: String): Seq[String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,6 @@ class InMemoryCatalog(
catalog(db).tables(table).table
}

override def getTableOption(db: String, table: String): Option[CatalogTable] = synchronized {
if (!tableExists(db, table)) None else Option(catalog(db).tables(table).table)
}

override def tableExists(db: String, table: String): Boolean = synchronized {
requireDbExists(db)
catalog(db).tables.contains(table)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,10 @@ class SessionCatalog(

/**
* Retrieve the metadata of an existing permanent table/view. If no database is specified,
* assume the table/view is in the current database. If the specified table/view is not found
* in the database then a [[NoSuchTableException]] is thrown.
* assume the table/view is in the current database.
*/
@throws[NoSuchDatabaseException]
@throws[NoSuchTableException]
def getTableMetadata(name: TableIdentifier): CatalogTable = {
val db = formatDatabaseName(name.database.getOrElse(getCurrentDatabase))
val table = formatTableName(name.table)
Expand All @@ -398,18 +399,6 @@ class SessionCatalog(
externalCatalog.getTable(db, table)
}

/**
* Retrieve the metadata of an existing metastore table.
* If no database is specified, assume the table is in the current database.
* If the specified table is not found in the database then return None if it doesn't exist.
*/
def getTableMetadataOption(name: TableIdentifier): Option[CatalogTable] = {
val db = formatDatabaseName(name.database.getOrElse(getCurrentDatabase))
val table = formatTableName(name.table)
requireDbExists(db)
externalCatalog.getTableOption(db, table)
}

/**
* Load files stored in given path into an existing metastore table.
* If no database is specified, assume the table is in the current database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,17 +510,6 @@ abstract class SessionCatalogSuite extends AnalysisTest {
}
}

test("get option of table metadata") {
withBasicCatalog { catalog =>
assert(catalog.getTableMetadataOption(TableIdentifier("tbl1", Some("db2")))
== Option(catalog.externalCatalog.getTable("db2", "tbl1")))
assert(catalog.getTableMetadataOption(TableIdentifier("unknown_table", Some("db2"))).isEmpty)
intercept[NoSuchDatabaseException] {
catalog.getTableMetadataOption(TableIdentifier("tbl1", Some("unknown_db")))
}
}
}

test("lookup table relation") {
withBasicCatalog { catalog =>
val tempTable1 = Range(1, 10, 1, 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,10 +669,6 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, hadoopConf: Configurat
restoreTableMetadata(getRawTable(db, table))
}

override def getTableOption(db: String, table: String): Option[CatalogTable] = withClient {
client.getTableOption(db, table).map(restoreTableMetadata)
}

/**
* Restores table metadata from the table properties. This method is kind of a opposite version
* of [[createTable]].
Expand Down