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 @@ -39,6 +39,9 @@ abstract class Catalog {

def dropDatabase(db: String, ignoreIfNotExists: Boolean, cascade: Boolean): Unit

/**
* Alter an existing database. This operation does not support renaming.
*/
def alterDatabase(db: String, dbDefinition: Database): Unit

def getDatabase(db: String): Database
Expand All @@ -57,6 +60,9 @@ abstract class Catalog {

def renameTable(db: String, oldName: String, newName: String): Unit

/**
* Alter an existing table. This operation does not support renaming.
*/
def alterTable(db: String, table: String, tableDefinition: Table): Unit

def getTable(db: String, table: String): Table
Expand All @@ -81,6 +87,9 @@ abstract class Catalog {
parts: Seq[PartitionSpec],
ignoreIfNotExists: Boolean): Unit

/**
* Alter an existing table partition and optionally override its spec.
*/
def alterPartition(
db: String,
table: String,
Expand All @@ -100,6 +109,9 @@ abstract class Catalog {

def dropFunction(db: String, funcName: String): Unit

/**
* Alter an existing function and optionally override its name.
*/
def alterFunction(db: String, funcName: String, funcDefinition: Function): Unit

def getFunction(db: String, funcName: String): Function
Expand Down Expand Up @@ -194,5 +206,8 @@ case class Database(


object Catalog {
/**
* Specifications of a table partition indexed by column name.
*/
type PartitionSpec = Map[String, String]
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import org.apache.spark.sql.AnalysisException
* Implementations of the [[Catalog]] interface can create test suites by extending this.
*/
abstract class CatalogTestCases extends SparkFunSuite {
private val storageFormat = StorageFormat("usa", "$", "zzz", "serde", Map.empty[String, String])
private val part1 = TablePartition(Map[String, String]("a" -> "1"), storageFormat)
private val part2 = TablePartition(Map[String, String]("b" -> "2"), storageFormat)
private val part3 = TablePartition(Map[String, String]("c" -> "3"), storageFormat)
private val storageFormat = StorageFormat("usa", "$", "zzz", "serde", Map())
private val part1 = TablePartition(Map("a" -> "1"), storageFormat)
private val part2 = TablePartition(Map("b" -> "2"), storageFormat)
private val part3 = TablePartition(Map("c" -> "3"), storageFormat)
private val funcClass = "org.apache.spark.myFunc"

protected def newEmptyCatalog(): Catalog
Expand All @@ -42,6 +42,8 @@ abstract class CatalogTestCases extends SparkFunSuite {
* db2
* - tbl1
* - tbl2
* - part1
* - part2
* - func1
*/
private def newBasicCatalog(): Catalog = {
Expand All @@ -50,8 +52,8 @@ abstract class CatalogTestCases extends SparkFunSuite {
catalog.createDatabase(newDb("db2"), ignoreIfExists = false)
catalog.createTable("db2", newTable("tbl1"), ignoreIfExists = false)
catalog.createTable("db2", newTable("tbl2"), ignoreIfExists = false)
catalog.createFunction("db2", newFunc("func1"), ignoreIfExists = false)
catalog.createPartitions("db2", "tbl2", Seq(part1, part2), ignoreIfExists = false)
catalog.createFunction("db2", newFunc("func1"), ignoreIfExists = false)
catalog
}

Expand Down