class SessionCatalog extends Logging
An internal catalog that is used by a Spark Session. This internal catalog serves as a proxy to the underlying metastore (e.g. Hive Metastore) and it also manages temporary views and functions of the Spark Session that it belongs to.
This class must be thread-safe.
- Alphabetic
- By Inheritance
- SessionCatalog
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new SessionCatalog(externalCatalog: ExternalCatalog)
- new SessionCatalog(externalCatalog: ExternalCatalog, functionRegistry: FunctionRegistry, conf: SQLConf)
- new SessionCatalog(externalCatalogBuilder: () ⇒ ExternalCatalog, globalTempViewManagerBuilder: () ⇒ GlobalTempViewManager, functionRegistry: FunctionRegistry, conf: SQLConf, hadoopConf: Configuration, parser: ParserInterface, functionResourceLoader: FunctionResourceLoader)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def alterDatabase(dbDefinition: CatalogDatabase): Unit
-
def
alterFunction(funcDefinition: CatalogFunction): Unit
overwrite a metastore function in the database specified in
funcDefinition..overwrite a metastore function in the database specified in
funcDefinition.. If no database is specified, assume the function is in the current database. -
def
alterPartitions(tableName: TableIdentifier, parts: Seq[CatalogTablePartition]): Unit
Alter one or many table partitions whose specs that match those specified in
parts, assuming the partitions exist.Alter one or many table partitions whose specs that match those specified in
parts, assuming the partitions exist.If no database is specified, assume the table is in the current database.
Note: If the underlying implementation does not support altering a certain field, this becomes a no-op.
-
def
alterTable(tableDefinition: CatalogTable): Unit
Alter the metadata of an existing metastore table identified by
tableDefinition.Alter the metadata of an existing metastore table identified by
tableDefinition.If no database is specified in
tableDefinition, assume the table is in the current database.Note: If the underlying implementation does not support altering a certain field, this becomes a no-op.
-
def
alterTableDataSchema(identifier: TableIdentifier, newDataSchema: StructType): Unit
Alter the data schema of a table identified by the provided table identifier.
Alter the data schema of a table identified by the provided table identifier. The new data schema should not have conflict column names with the existing partition columns, and should still contain all the existing data columns.
- identifier
TableIdentifier
- newDataSchema
Updated data schema to be used for the table
-
def
alterTableStats(identifier: TableIdentifier, newStats: Option[CatalogStatistics]): Unit
Alter Spark's statistics of an existing metastore table identified by the provided table identifier.
-
def
alterTempViewDefinition(name: TableIdentifier, viewDefinition: LogicalPlan): Boolean
Alter the definition of a local/global temp view matching the given name, returns true if a temp view is matched and altered, false otherwise.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
cacheTable(t: QualifiedTableName, l: LogicalPlan): Unit
This method provides a way to cache a plan.
-
def
clearTempTables(): Unit
Drop all existing temporary views.
Drop all existing temporary views. For testing only.
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- def createDatabase(dbDefinition: CatalogDatabase, ignoreIfExists: Boolean): Unit
-
def
createFunction(funcDefinition: CatalogFunction, ignoreIfExists: Boolean): Unit
Create a function in the database specified in
funcDefinition.Create a function in the database specified in
funcDefinition. If no such database is specified, create it in the current database. -
def
createGlobalTempView(name: String, viewDefinition: LogicalPlan, overrideIfExists: Boolean): Unit
Create a global temporary view.
-
def
createPartitions(tableName: TableIdentifier, parts: Seq[CatalogTablePartition], ignoreIfExists: Boolean): Unit
Create partitions in an existing table, assuming it exists.
Create partitions in an existing table, assuming it exists. If no database is specified, assume the table is in the current database.
-
def
createTable(tableDefinition: CatalogTable, ignoreIfExists: Boolean, validateLocation: Boolean = true): Unit
Create a metastore table in the database specified in
tableDefinition.Create a metastore table in the database specified in
tableDefinition. If no such database is specified, create it in the current database. -
def
createTempView(name: String, tableDefinition: LogicalPlan, overrideIfExists: Boolean): Unit
Create a local temporary view.
-
var
currentDb: String
- Attributes
- protected
- def databaseExists(db: String): Boolean
- def defaultTablePath(tableIdent: TableIdentifier): URI
- def dropDatabase(db: String, ignoreIfNotExists: Boolean, cascade: Boolean): Unit
-
def
dropFunction(name: FunctionIdentifier, ignoreIfNotExists: Boolean): Unit
Drop a metastore function.
Drop a metastore function. If no database is specified, assume the function is in the current database.
-
def
dropGlobalTempView(name: String): Boolean
Drop a global temporary view.
Drop a global temporary view.
Returns true if this view is dropped successfully, false otherwise.
-
def
dropPartitions(tableName: TableIdentifier, specs: Seq[TablePartitionSpec], ignoreIfNotExists: Boolean, purge: Boolean, retainData: Boolean): Unit
Drop partitions from a table, assuming they exist.
Drop partitions from a table, assuming they exist. If no database is specified, assume the table is in the current database.
-
def
dropTable(name: TableIdentifier, ignoreIfNotExists: Boolean, purge: Boolean): Unit
Drop a table.
Drop a table.
If a database is specified in
name, this will drop the table from that database. If no database is specified, this will first attempt to drop a temporary view with the same name, then, if that does not exist, drop the table from the current database. -
def
dropTempFunction(name: String, ignoreIfNotExists: Boolean): Unit
Drop a temporary function.
-
def
dropTempView(name: String): Boolean
Drop a local temporary view.
Drop a local temporary view.
Returns true if this view is dropped successfully, false otherwise.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- lazy val externalCatalog: ExternalCatalog
-
def
failFunctionLookup(name: FunctionIdentifier, cause: Option[Throwable] = None): Nothing
- Attributes
- protected[sql]
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
formatDatabaseName(name: String): String
Format database name, taking into account case sensitivity.
Format database name, taking into account case sensitivity.
- Attributes
- protected[this]
-
def
formatTableName(name: String): String
Format table name, taking into account case sensitivity.
Format table name, taking into account case sensitivity.
- Attributes
- protected[this]
-
def
functionExists(name: FunctionIdentifier): Boolean
Check if the function with the specified name exists
-
def
getCachedPlan(t: QualifiedTableName, c: Callable[LogicalPlan]): LogicalPlan
This method provides a way to get a cached plan.
-
def
getCachedTable(key: QualifiedTableName): LogicalPlan
This method provides a way to get a cached plan if the key exists.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getCurrentDatabase: String
- def getDatabaseMetadata(db: String): CatalogDatabase
-
def
getDefaultDBPath(db: String): URI
Get the path for creating a non-default database when database location is not provided by users.
-
def
getFunctionMetadata(name: FunctionIdentifier): CatalogFunction
Retrieve the metadata of a metastore function.
Retrieve the metadata of a metastore function.
If a database is specified in
name, this will return the function in that database. If no database is specified, this will return the function in the current database. -
def
getGlobalTempView(name: String): Option[LogicalPlan]
Return a global temporary view exactly as it was stored.
-
def
getPartition(tableName: TableIdentifier, spec: TablePartitionSpec): CatalogTablePartition
Retrieve the metadata of a table partition, assuming it exists.
Retrieve the metadata of a table partition, assuming it exists. If no database is specified, assume the table is in the current database.
- def getRelation(metadata: CatalogTable): LogicalPlan
-
def
getTableMetadata(name: TableIdentifier): CatalogTable
Retrieve the metadata of an existing permanent table/view.
Retrieve the metadata of an existing permanent table/view. If no database is specified, assume the table/view is in the current database.
- Annotations
- @throws( ... ) @throws( ... )
-
def
getTablesByName(names: Seq[TableIdentifier]): Seq[CatalogTable]
Retrieve all metadata of existing permanent tables/views.
Retrieve all metadata of existing permanent tables/views. If no database is specified, assume the table/view is in the current database. Only the tables/views belong to the same database that can be retrieved are returned. For example, if none of the requested tables could be retrieved, an empty list is returned. There is no guarantee of ordering of the returned tables.
- Annotations
- @throws( ... )
-
def
getTempView(name: String): Option[LogicalPlan]
Return a local temporary view exactly as it was stored.
- def getTempViewNames(): Seq[String]
-
def
getTempViewOrPermanentTableMetadata(name: TableIdentifier): CatalogTable
Retrieve the metadata of an existing temporary view or permanent table/view.
Retrieve the metadata of an existing temporary view or permanent table/view.
If a database is specified in
name, this will return the metadata of table/view in that database. If no database is specified, this will first attempt to get the metadata of a temporary view with the same name, then, if that does not exist, return the metadata of table/view in the current database. - lazy val globalTempViewManager: GlobalTempViewManager
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
- Attributes
- protected
- Definition Classes
- Logging
-
def
initializeLogIfNecessary(isInterpreter: Boolean): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
invalidateAllCachedTables(): Unit
This method provides a way to invalidate all the cached plans.
-
def
invalidateCachedTable(key: QualifiedTableName): Unit
This method provides a way to invalidate a cached plan.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isPersistentFunction(name: FunctionIdentifier): Boolean
Returns whether it is a persistent function.
Returns whether it is a persistent function. If not existed, returns false.
-
def
isRegisteredFunction(name: FunctionIdentifier): Boolean
Return whether this function has been registered in the function registry of the current session.
Return whether this function has been registered in the function registry of the current session. If not existed, return false.
- def isTempFunction(name: String): Boolean
- def isTempView(nameParts: Seq[String]): Boolean
-
def
isTemporaryFunction(name: FunctionIdentifier): Boolean
Returns whether it is a temporary function.
Returns whether it is a temporary function. If not existed, returns false.
-
def
isTemporaryTable(name: TableIdentifier): Boolean
Return whether a table with the specified name is a temporary view.
Return whether a table with the specified name is a temporary view.
Note: The temporary view cache is checked only when database is not explicitly specified.
-
def
isTraceEnabled(): Boolean
- Attributes
- protected
- Definition Classes
- Logging
- def isView(nameParts: Seq[String]): Boolean
- def listDatabases(pattern: String): Seq[String]
- def listDatabases(): Seq[String]
-
def
listFunctions(db: String, pattern: String): Seq[(FunctionIdentifier, String)]
List all matching functions in the specified database, including temporary functions.
List all matching functions in the specified database, including temporary functions. This returns the function identifier and the scope in which it was defined (system or user defined).
-
def
listFunctions(db: String): Seq[(FunctionIdentifier, String)]
List all functions in the specified database, including temporary functions.
List all functions in the specified database, including temporary functions. This returns the function identifier and the scope in which it was defined (system or user defined).
-
def
listLocalTempViews(pattern: String): Seq[TableIdentifier]
List all matching local temporary views.
-
def
listPartitionNames(tableName: TableIdentifier, partialSpec: Option[TablePartitionSpec] = None): Seq[String]
List the names of all partitions that belong to the specified table, assuming it exists.
List the names of all partitions that belong to the specified table, assuming it exists.
A partial partition spec may optionally be provided to filter the partitions returned. For instance, if there exist partitions (a='1', b='2'), (a='1', b='3') and (a='2', b='4'), then a partial spec of (a='1') will return the first two only.
-
def
listPartitions(tableName: TableIdentifier, partialSpec: Option[TablePartitionSpec] = None): Seq[CatalogTablePartition]
List the metadata of all partitions that belong to the specified table, assuming it exists.
List the metadata of all partitions that belong to the specified table, assuming it exists.
A partial partition spec may optionally be provided to filter the partitions returned. For instance, if there exist partitions (a='1', b='2'), (a='1', b='3') and (a='2', b='4'), then a partial spec of (a='1') will return the first two only.
-
def
listPartitionsByFilter(tableName: TableIdentifier, predicates: Seq[Expression]): Seq[CatalogTablePartition]
List the metadata of partitions that belong to the specified table, assuming it exists, that satisfy the given partition-pruning predicate expressions.
-
def
listTables(db: String, pattern: String, includeLocalTempViews: Boolean): Seq[TableIdentifier]
List all matching tables in the specified database, including local temporary views if includeLocalTempViews is enabled.
List all matching tables in the specified database, including local temporary views if includeLocalTempViews is enabled.
Note that, if the specified database is global temporary view database, we will list global temporary views.
-
def
listTables(db: String, pattern: String): Seq[TableIdentifier]
List all matching tables in the specified database, including local temporary views.
List all matching tables in the specified database, including local temporary views.
Note that, if the specified database is global temporary view database, we will list global temporary views.
-
def
listTables(db: String): Seq[TableIdentifier]
List all tables in the specified database, including local temporary views.
List all tables in the specified database, including local temporary views.
Note that, if the specified database is global temporary view database, we will list global temporary views.
-
def
listViews(db: String, pattern: String): Seq[TableIdentifier]
List all matching views in the specified database, including local temporary views.
-
def
loadFunctionResources(resources: Seq[FunctionResource]): Unit
Loads resources such as JARs and Files for a function.
Loads resources such as JARs and Files for a function. Every resource is represented by a tuple (resource type, resource uri).
-
def
loadPartition(name: TableIdentifier, loadPath: String, spec: TablePartitionSpec, isOverwrite: Boolean, inheritTableSpecs: Boolean, isSrcLocal: Boolean): Unit
Load files stored in given path into the partition of an existing metastore table.
Load files stored in given path into the partition 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 a NoSuchTableException is thrown.
-
def
loadTable(name: TableIdentifier, loadPath: String, isOverwrite: Boolean, isSrcLocal: Boolean): Unit
Load files stored in given path into an existing metastore 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. If the specified table is not found in the database then a NoSuchTableException is thrown.
-
def
log: Logger
- Attributes
- protected
- Definition Classes
- Logging
-
def
logDebug(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logDebug(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logError(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logError(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logInfo(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logInfo(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logName: String
- Attributes
- protected
- Definition Classes
- Logging
-
def
logTrace(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logTrace(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logWarning(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logWarning(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
lookupFunction(name: FunctionIdentifier, children: Seq[Expression]): Expression
Return an Expression that represents the specified function, assuming it exists.
Return an Expression that represents the specified function, assuming it exists.
For a temporary function or a permanent function that has been loaded, this method will simply lookup the function through the FunctionRegistry and create an expression based on the builder.
For a permanent function that has not been loaded, we will first fetch its metadata from the underlying external catalog. Then, we will load all resources associated with this function (i.e. jars and files). Finally, we create a function builder based on the function class and put the builder into the FunctionRegistry. The name of this function in the FunctionRegistry will be
databaseName.functionName. -
def
lookupFunctionInfo(name: FunctionIdentifier): ExpressionInfo
Look up the ExpressionInfo associated with the specified function, assuming it exists.
- def lookupGlobalTempView(db: String, table: String): Option[SubqueryAlias]
-
def
lookupRelation(name: TableIdentifier): LogicalPlan
Return a LogicalPlan that represents the given table or view.
Return a LogicalPlan that represents the given table or view.
If a database is specified in
name, this will return the table/view from that database. If no database is specified, this will first attempt to return a temporary view with the same name, then, if that does not exist, return the table/view from the current database.Note that, the global temp view database is also valid here, this will return the global temp view matching the given name.
If the relation is a view, we generate a View operator from the view description, and wrap the logical plan in a SubqueryAlias which will track the name of the view. SubqueryAlias will also keep track of the name and database(optional) of the table/view
- name
The name of the table/view that we look up.
- def lookupTempView(table: String): Option[SubqueryAlias]
-
def
makeFunctionExpression(name: String, clazz: Class[_], input: Seq[Expression]): Expression
Constructs a Expression based on the provided class that represents a function.
Constructs a Expression based on the provided class that represents a function.
This performs reflection to decide what type of Expression to return in the builder.
- Attributes
- protected
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
refreshTable(name: TableIdentifier): Unit
Refresh the cache entry for a metastore table, if any.
-
def
registerFunction(funcDefinition: CatalogFunction, overrideIfExists: Boolean, functionBuilder: Option[FunctionBuilder] = None): Unit
Registers a temporary or permanent function into a session-specific FunctionRegistry
-
def
renamePartitions(tableName: TableIdentifier, specs: Seq[TablePartitionSpec], newSpecs: Seq[TablePartitionSpec]): Unit
Override the specs of one or many existing table partitions, assuming they exist.
Override the specs of one or many existing table partitions, assuming they exist.
This assumes index i of
specscorresponds to index i ofnewSpecs. If no database is specified, assume the table is in the current database. -
def
renameTable(oldName: TableIdentifier, newName: TableIdentifier): Unit
Rename a table.
Rename a table.
If a database is specified in
oldName, this will rename the table in that database. If no database is specified, this will first attempt to rename a temporary view with the same name, then, if that does not exist, rename the table in the current database.This assumes the database specified in
newNamematches the one inoldName. -
def
reset(): Unit
Drop all existing databases (except "default"), tables, partitions and functions, and set the current database to "default".
Drop all existing databases (except "default"), tables, partitions and functions, and set the current database to "default".
This is mainly used for tests.
- def setCurrentDatabase(db: String): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
tableExists(name: TableIdentifier): Boolean
Return whether a table/view with the specified name exists.
Return whether a table/view with the specified name exists. If no database is specified, check with current database.
-
val
tempViews: HashMap[String, LogicalPlan]
List of temporary views, mapping from table name to their logical plan.
List of temporary views, mapping from table name to their logical plan.
- Attributes
- protected
-
def
toString(): String
- Definition Classes
- AnyRef → Any
- def validateTableLocation(table: CatalogTable): Unit
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()