public class RESTCatalog extends java.lang.Object implements Catalog, SupportsNamespaces, Configurable<org.apache.hadoop.conf.Configuration>, java.io.Closeable
Catalog.TableBuilder| Constructor and Description |
|---|
RESTCatalog() |
RESTCatalog(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,RESTClient> clientBuilder) |
RESTCatalog(SessionCatalog.SessionContext context,
java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,RESTClient> clientBuilder) |
| Modifier and Type | Method and Description |
|---|---|
Catalog.TableBuilder |
buildTable(TableIdentifier ident,
Schema schema)
/** Instantiate a builder to either create a table or start a create/replace transaction.
|
void |
close() |
void |
createNamespace(Namespace ns,
java.util.Map<java.lang.String,java.lang.String> props)
Create a namespace in the catalog.
|
Table |
createTable(TableIdentifier identifier,
Schema schema)
Create an unpartitioned table.
|
Table |
createTable(TableIdentifier ident,
Schema schema,
PartitionSpec spec)
Create a table.
|
Table |
createTable(TableIdentifier ident,
Schema schema,
PartitionSpec spec,
java.util.Map<java.lang.String,java.lang.String> props)
Create a table.
|
Table |
createTable(TableIdentifier ident,
Schema schema,
PartitionSpec spec,
java.lang.String location,
java.util.Map<java.lang.String,java.lang.String> props)
Create a table.
|
boolean |
dropNamespace(Namespace ns)
Drop a namespace.
|
boolean |
dropTable(TableIdentifier ident)
Drop a table and delete all data and metadata files.
|
boolean |
dropTable(TableIdentifier ident,
boolean purge)
Drop a table; optionally delete data and metadata files.
|
void |
initialize(java.lang.String name,
java.util.Map<java.lang.String,java.lang.String> props)
Initialize a catalog given a custom name and a map of catalog properties.
|
void |
invalidateTable(TableIdentifier ident)
Invalidate cached table metadata from current catalog.
|
java.util.List<Namespace> |
listNamespaces(Namespace ns)
List namespaces from the namespace.
|
java.util.List<TableIdentifier> |
listTables(Namespace ns)
Return all the identifiers under this namespace.
|
java.util.Map<java.lang.String,java.lang.String> |
loadNamespaceMetadata(Namespace ns)
Load metadata properties for a namespace.
|
Table |
loadTable(TableIdentifier ident)
Load a table.
|
java.lang.String |
name()
Return the name for this catalog.
|
Transaction |
newCreateTableTransaction(TableIdentifier identifier,
Schema schema)
Start a transaction to create a table.
|
Transaction |
newCreateTableTransaction(TableIdentifier ident,
Schema schema,
PartitionSpec spec)
Start a transaction to create a table.
|
Transaction |
newCreateTableTransaction(TableIdentifier ident,
Schema schema,
PartitionSpec spec,
java.util.Map<java.lang.String,java.lang.String> props)
Start a transaction to create a table.
|
Transaction |
newCreateTableTransaction(TableIdentifier ident,
Schema schema,
PartitionSpec spec,
java.lang.String location,
java.util.Map<java.lang.String,java.lang.String> props)
Start a transaction to create a table.
|
Transaction |
newReplaceTableTransaction(TableIdentifier ident,
Schema schema,
boolean orCreate)
Start a transaction to replace a table.
|
Transaction |
newReplaceTableTransaction(TableIdentifier ident,
Schema schema,
PartitionSpec spec,
boolean orCreate)
Start a transaction to replace a table.
|
Transaction |
newReplaceTableTransaction(TableIdentifier ident,
Schema schema,
PartitionSpec spec,
java.util.Map<java.lang.String,java.lang.String> props,
boolean orCreate)
Start a transaction to replace a table.
|
Transaction |
newReplaceTableTransaction(TableIdentifier ident,
Schema schema,
PartitionSpec spec,
java.lang.String location,
java.util.Map<java.lang.String,java.lang.String> props,
boolean orCreate)
Start a transaction to replace a table.
|
java.util.Map<java.lang.String,java.lang.String> |
properties() |
Table |
registerTable(TableIdentifier ident,
java.lang.String metadataFileLocation)
Register a table with the catalog if it does not exist.
|
boolean |
removeProperties(Namespace ns,
java.util.Set<java.lang.String> props)
Remove a set of property keys from a namespace in the catalog.
|
void |
renameTable(TableIdentifier from,
TableIdentifier to)
Rename a table.
|
void |
setConf(org.apache.hadoop.conf.Configuration conf) |
boolean |
setProperties(Namespace ns,
java.util.Map<java.lang.String,java.lang.String> props)
Set a collection of properties on a namespace in the catalog.
|
boolean |
tableExists(TableIdentifier ident)
Check whether table exists.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateNamespace, listNamespaces, namespaceExistspublic RESTCatalog()
public RESTCatalog(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,RESTClient> clientBuilder)
public RESTCatalog(SessionCatalog.SessionContext context, java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,RESTClient> clientBuilder)
public void initialize(java.lang.String name,
java.util.Map<java.lang.String,java.lang.String> props)
CatalogA custom Catalog implementation must have a no-arg constructor. A compute engine like Spark or Flink will first initialize the catalog without any arguments, and then call this method to complete catalog initialization with properties passed into the engine.
initialize in interface Catalogname - a custom name for the catalogprops - catalog propertiespublic java.lang.String name()
Catalogpublic java.util.Map<java.lang.String,java.lang.String> properties()
public java.util.List<TableIdentifier> listTables(Namespace ns)
CataloglistTables in interface Catalogns - a namespacepublic boolean tableExists(TableIdentifier ident)
CatalogtableExists in interface Catalogident - a table identifierpublic Table loadTable(TableIdentifier ident)
Catalogpublic void invalidateTable(TableIdentifier ident)
CatalogIf the table is already loaded or cached, drop cached data. If the table does not exist or is not cached, do nothing.
invalidateTable in interface Catalogident - a table identifierpublic Catalog.TableBuilder buildTable(TableIdentifier ident, Schema schema)
CatalogbuildTable in interface Catalogident - a table identifierschema - a schemapublic Table createTable(TableIdentifier ident, Schema schema, PartitionSpec spec, java.lang.String location, java.util.Map<java.lang.String,java.lang.String> props)
CatalogcreateTable in interface Catalogident - a table identifierschema - a schemaspec - a partition speclocation - a location for the table; leave null if unspecifiedprops - a string map of table propertiespublic Table createTable(TableIdentifier ident, Schema schema, PartitionSpec spec, java.util.Map<java.lang.String,java.lang.String> props)
CatalogcreateTable in interface Catalogident - a table identifierschema - a schemaspec - a partition specprops - a string map of table propertiespublic Table createTable(TableIdentifier ident, Schema schema, PartitionSpec spec)
CatalogcreateTable in interface Catalogident - a table identifierschema - a schemaspec - a partition specpublic Table createTable(TableIdentifier identifier, Schema schema)
CatalogcreateTable in interface Catalogidentifier - a table identifierschema - a schemapublic Transaction newCreateTableTransaction(TableIdentifier ident, Schema schema, PartitionSpec spec, java.lang.String location, java.util.Map<java.lang.String,java.lang.String> props)
CatalognewCreateTableTransaction in interface Catalogident - a table identifierschema - a schemaspec - a partition speclocation - a location for the table; leave null if unspecifiedprops - a string map of table propertiesTransaction to create the tablepublic Transaction newCreateTableTransaction(TableIdentifier ident, Schema schema, PartitionSpec spec, java.util.Map<java.lang.String,java.lang.String> props)
CatalognewCreateTableTransaction in interface Catalogident - a table identifierschema - a schemaspec - a partition specprops - a string map of table propertiesTransaction to create the tablepublic Transaction newCreateTableTransaction(TableIdentifier ident, Schema schema, PartitionSpec spec)
CatalognewCreateTableTransaction in interface Catalogident - a table identifierschema - a schemaspec - a partition specTransaction to create the tablepublic Transaction newCreateTableTransaction(TableIdentifier identifier, Schema schema)
CatalognewCreateTableTransaction in interface Catalogidentifier - a table identifierschema - a schemaTransaction to create the tablepublic Transaction newReplaceTableTransaction(TableIdentifier ident, Schema schema, PartitionSpec spec, java.lang.String location, java.util.Map<java.lang.String,java.lang.String> props, boolean orCreate)
CatalognewReplaceTableTransaction in interface Catalogident - a table identifierschema - a schemaspec - a partition speclocation - a location for the table; leave null if unspecifiedprops - a string map of table propertiesorCreate - whether to create the table if not existsTransaction to replace the tablepublic Transaction newReplaceTableTransaction(TableIdentifier ident, Schema schema, PartitionSpec spec, java.util.Map<java.lang.String,java.lang.String> props, boolean orCreate)
CatalognewReplaceTableTransaction in interface Catalogident - a table identifierschema - a schemaspec - a partition specprops - a string map of table propertiesorCreate - whether to create the table if not existsTransaction to replace the tablepublic Transaction newReplaceTableTransaction(TableIdentifier ident, Schema schema, PartitionSpec spec, boolean orCreate)
CatalognewReplaceTableTransaction in interface Catalogident - a table identifierschema - a schemaspec - a partition specorCreate - whether to create the table if not existsTransaction to replace the tablepublic Transaction newReplaceTableTransaction(TableIdentifier ident, Schema schema, boolean orCreate)
CatalognewReplaceTableTransaction in interface Catalogident - a table identifierschema - a schemaorCreate - whether to create the table if not existsTransaction to replace the tablepublic boolean dropTable(TableIdentifier ident)
Catalogpublic boolean dropTable(TableIdentifier ident, boolean purge)
CatalogIf purge is set to true the implementation should delete all data and metadata files.
public void renameTable(TableIdentifier from, TableIdentifier to)
CatalogrenameTable in interface Catalogfrom - identifier of the table to renameto - new table namepublic Table registerTable(TableIdentifier ident, java.lang.String metadataFileLocation)
CatalogregisterTable in interface Catalogident - a table identifiermetadataFileLocation - the location of a metadata filepublic void createNamespace(Namespace ns, java.util.Map<java.lang.String,java.lang.String> props)
SupportsNamespacescreateNamespace in interface SupportsNamespacesns - a multi-part namespaceprops - a string Map of properties for the given namespacepublic java.util.List<Namespace> listNamespaces(Namespace ns) throws NoSuchNamespaceException
SupportsNamespacesFor example, if table a.b.t exists, use 'SELECT NAMESPACE IN a' this method must return
Namepace.of("a","b") Namespace.
listNamespaces in interface SupportsNamespacesNamespace namesNoSuchNamespaceException - If the namespace does not exist (optional)public java.util.Map<java.lang.String,java.lang.String> loadNamespaceMetadata(Namespace ns) throws NoSuchNamespaceException
SupportsNamespacesloadNamespaceMetadata in interface SupportsNamespacesns - a namespace. NamespaceNoSuchNamespaceException - If the namespace does not exist (optional)public boolean dropNamespace(Namespace ns) throws NamespaceNotEmptyException
SupportsNamespacesdropNamespace in interface SupportsNamespacesns - a namespace. NamespaceNamespaceNotEmptyException - If the namespace is not emptypublic boolean setProperties(Namespace ns, java.util.Map<java.lang.String,java.lang.String> props) throws NoSuchNamespaceException
SupportsNamespacesProperties that are not in the given map are not modified or removed by this method.
setProperties in interface SupportsNamespacesns - a namespace. Namespaceprops - a collection of metadata to apply to the namespaceNoSuchNamespaceException - If the namespace does not exist (optional)public boolean removeProperties(Namespace ns, java.util.Set<java.lang.String> props) throws NoSuchNamespaceException
SupportsNamespacesProperties that are not in the given set are not modified or removed by this method.
removeProperties in interface SupportsNamespacesns - a namespace. Namespaceprops - a collection of metadata to apply to the namespaceNoSuchNamespaceException - If the namespace does not exist (optional)public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf in interface Configurable<org.apache.hadoop.conf.Configuration>public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException