@Experimental public abstract class DelegatingCatalogExtension extends Object implements CatalogExtension
CatalogExtension, which implements all the catalog functions
by calling the built-in session catalog directly. This is created for convenience, so that users
only need to override some methods where they want to apply custom logic. For example, they can
override createTable, do something else before calling super.createTable.PROP_COMMENT, PROP_LOCATION, PROP_PROVIDER, RESERVED_PROPERTIESPROP_COMMENT, PROP_LOCATION, PROP_OWNER_NAME, PROP_OWNER_TYPE, RESERVED_PROPERTIES| Constructor and Description |
|---|
DelegatingCatalogExtension() |
| Modifier and Type | Method and Description |
|---|---|
void |
alterNamespace(String[] namespace,
NamespaceChange... changes)
Apply a set of metadata changes to a namespace in the catalog.
|
Table |
alterTable(Identifier ident,
TableChange... changes)
Apply a set of
changes to a table in the catalog. |
void |
createNamespace(String[] namespace,
java.util.Map<String,String> metadata)
Create a namespace in the catalog.
|
Table |
createTable(Identifier ident,
StructType schema,
Transform[] partitions,
java.util.Map<String,String> properties)
Create a table in the catalog.
|
String[] |
defaultNamespace()
Return a default namespace for the catalog.
|
boolean |
dropNamespace(String[] namespace)
Drop a namespace from the catalog, recursively dropping all objects within the namespace.
|
boolean |
dropTable(Identifier ident)
Drop a table in the catalog.
|
void |
initialize(String name,
CaseInsensitiveStringMap options)
Called to initialize configuration.
|
void |
invalidateTable(Identifier ident)
Invalidate cached table metadata for an
identifier. |
String[][] |
listNamespaces()
List top-level namespaces from the catalog.
|
String[][] |
listNamespaces(String[] namespace)
List namespaces in a namespace.
|
Identifier[] |
listTables(String[] namespace)
List the tables in a namespace from the catalog.
|
java.util.Map<String,String> |
loadNamespaceMetadata(String[] namespace)
Load metadata properties for a namespace.
|
Table |
loadTable(Identifier ident)
Load table metadata by
identifier from the catalog. |
String |
name()
Called to get this catalog's name.
|
boolean |
namespaceExists(String[] namespace)
Test whether a namespace exists.
|
void |
renameTable(Identifier oldIdent,
Identifier newIdent)
Renames a table in the catalog.
|
void |
setDelegateCatalog(CatalogPlugin delegate)
This will be called only once by Spark to pass in the Spark built-in session catalog, after
CatalogPlugin.initialize(String, CaseInsensitiveStringMap) is called. |
boolean |
tableExists(Identifier ident)
Test whether a table exists using an
identifier from the catalog. |
public final void setDelegateCatalog(CatalogPlugin delegate)
CatalogExtensionCatalogPlugin.initialize(String, CaseInsensitiveStringMap) is called.setDelegateCatalog in interface CatalogExtensionpublic String name()
CatalogPlugin
This method is only called after CatalogPlugin.initialize(String, CaseInsensitiveStringMap) is
called to pass the catalog's name.
name in interface CatalogPluginpublic final void initialize(String name,
CaseInsensitiveStringMap options)
CatalogPluginThis method is called once, just after the provider is instantiated.
initialize in interface CatalogPluginname - the name used to identify and load this catalogoptions - a case-insensitive string map of configurationpublic Identifier[] listTables(String[] namespace) throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
TableCatalogIf the catalog supports views, this must return identifiers for only tables and not views.
listTables in interface TableCatalognamespace - a multi-part namespaceorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - If the namespace does not exist (optional).public Table loadTable(Identifier ident) throws org.apache.spark.sql.catalyst.analysis.NoSuchTableException
TableCatalogidentifier from the catalog.
If the catalog supports views and contains a view for the identifier and not a table, this
must throw NoSuchTableException.
loadTable in interface TableCatalogident - a table identifierorg.apache.spark.sql.catalyst.analysis.NoSuchTableException - If the table doesn't exist or is a viewpublic void invalidateTable(Identifier ident)
TableCatalogidentifier.
If the table is already loaded or cached, drop cached data. If the table does not exist or is not cached, do nothing. Calling this method should not query remote services.
invalidateTable in interface TableCatalogident - a table identifierpublic boolean tableExists(Identifier ident)
TableCatalogidentifier from the catalog.
If the catalog supports views and contains a view for the identifier and not a table, this must return false.
tableExists in interface TableCatalogident - a table identifierpublic Table createTable(Identifier ident, StructType schema, Transform[] partitions, java.util.Map<String,String> properties) throws org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException, org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
TableCatalogcreateTable in interface TableCatalogident - a table identifierschema - the schema of the new table, as a struct typepartitions - transforms to use for partitioning data in the tableproperties - a string map of table propertiesorg.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException - If a table or view already exists for the identifierorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - If the identifier namespace does not exist (optional)public Table alterTable(Identifier ident, TableChange... changes) throws org.apache.spark.sql.catalyst.analysis.NoSuchTableException
TableCatalogchanges to a table in the catalog.
Implementations may reject the requested changes. If any change is rejected, none of the changes should be applied to the table.
If the catalog supports views and contains a view for the identifier and not a table, this
must throw NoSuchTableException.
alterTable in interface TableCatalogident - a table identifierchanges - changes to apply to the tableorg.apache.spark.sql.catalyst.analysis.NoSuchTableException - If the table doesn't exist or is a viewpublic boolean dropTable(Identifier ident)
TableCatalogIf the catalog supports views and contains a view for the identifier and not a table, this must not drop the view and must return false.
dropTable in interface TableCatalogident - a table identifierpublic void renameTable(Identifier oldIdent, Identifier newIdent) throws org.apache.spark.sql.catalyst.analysis.NoSuchTableException, org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException
TableCatalog
If the catalog supports views and contains a view for the old identifier and not a table, this
throws NoSuchTableException. Additionally, if the new identifier is a table or a view,
this throws TableAlreadyExistsException.
If the catalog does not support table renames between namespaces, it throws
UnsupportedOperationException.
renameTable in interface TableCatalogoldIdent - the table identifier of the existing table to renamenewIdent - the new table identifier of the tableorg.apache.spark.sql.catalyst.analysis.NoSuchTableException - If the table to rename doesn't exist or is a vieworg.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException - If the new table name already exists or is a viewpublic String[] defaultNamespace()
SupportsNamespacesWhen this catalog is set as the current catalog, the namespace returned by this method will be set as the current namespace.
The namespace returned by this method is not required to exist.
defaultNamespace in interface SupportsNamespacespublic String[][] listNamespaces()
throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
SupportsNamespacesIf an object such as a table, view, or function exists, its parent namespaces must also exist and must be returned by this discovery method. For example, if table a.b.t exists, this method must return ["a"] in the result array.
listNamespaces in interface SupportsNamespacesorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceExceptionpublic String[][] listNamespaces(String[] namespace)
throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
SupportsNamespacesIf an object such as a table, view, or function exists, its parent namespaces must also exist and must be returned by this discovery method. For example, if table a.b.t exists, this method invoked as listNamespaces(["a"]) must return ["a", "b"] in the result array.
listNamespaces in interface SupportsNamespacesnamespace - a multi-part namespaceorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - If the namespace does not exist (optional)public boolean namespaceExists(String[] namespace)
SupportsNamespacesIf an object such as a table, view, or function exists, its parent namespaces must also exist. For example, if table a.b.t exists, this method invoked as namespaceExists(["a"]) or namespaceExists(["a", "b"]) must return true.
namespaceExists in interface SupportsNamespacesnamespace - a multi-part namespacepublic java.util.Map<String,String> loadNamespaceMetadata(String[] namespace)
throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
SupportsNamespacesloadNamespaceMetadata in interface SupportsNamespacesnamespace - a multi-part namespaceorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - If the namespace does not exist (optional)public void createNamespace(String[] namespace,
java.util.Map<String,String> metadata)
throws org.apache.spark.sql.catalyst.analysis.NamespaceAlreadyExistsException
SupportsNamespacescreateNamespace in interface SupportsNamespacesnamespace - a multi-part namespacemetadata - a string map of properties for the given namespaceorg.apache.spark.sql.catalyst.analysis.NamespaceAlreadyExistsException - If the namespace already existspublic void alterNamespace(String[] namespace,
NamespaceChange... changes)
throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
SupportsNamespacesalterNamespace in interface SupportsNamespacesnamespace - a multi-part namespacechanges - a collection of changes to apply to the namespaceorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - If the namespace does not exist (optional)public boolean dropNamespace(String[] namespace)
throws org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
SupportsNamespaces
If the catalog implementation does not support this operation, it may throw
UnsupportedOperationException.
dropNamespace in interface SupportsNamespacesnamespace - a multi-part namespaceorg.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException - If the namespace does not exist (optional)