public class RESTCatalog extends java.lang.Object implements Catalog, SupportsNamespaces, Configurable<java.lang.Object>, 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(java.lang.Object 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, wait
createNamespace, listNamespaces, namespaceExists
public 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)
Catalog
A 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 Catalog
name
- a custom name for the catalogprops
- catalog propertiespublic java.lang.String name()
Catalog
public java.util.Map<java.lang.String,java.lang.String> properties()
public java.util.List<TableIdentifier> listTables(Namespace ns)
Catalog
listTables
in interface Catalog
ns
- a namespacepublic boolean tableExists(TableIdentifier ident)
Catalog
tableExists
in interface Catalog
ident
- a table identifierpublic Table loadTable(TableIdentifier ident)
Catalog
public void invalidateTable(TableIdentifier ident)
Catalog
If 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 Catalog
ident
- a table identifierpublic Catalog.TableBuilder buildTable(TableIdentifier ident, Schema schema)
Catalog
buildTable
in interface Catalog
ident
- 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)
Catalog
createTable
in interface Catalog
ident
- 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)
Catalog
createTable
in interface Catalog
ident
- a table identifierschema
- a schemaspec
- a partition specprops
- a string map of table propertiespublic Table createTable(TableIdentifier ident, Schema schema, PartitionSpec spec)
Catalog
createTable
in interface Catalog
ident
- a table identifierschema
- a schemaspec
- a partition specpublic Table createTable(TableIdentifier identifier, Schema schema)
Catalog
createTable
in interface Catalog
identifier
- 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)
Catalog
newCreateTableTransaction
in interface Catalog
ident
- 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)
Catalog
newCreateTableTransaction
in interface Catalog
ident
- 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)
Catalog
newCreateTableTransaction
in interface Catalog
ident
- a table identifierschema
- a schemaspec
- a partition specTransaction
to create the tablepublic Transaction newCreateTableTransaction(TableIdentifier identifier, Schema schema)
Catalog
newCreateTableTransaction
in interface Catalog
identifier
- 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)
Catalog
newReplaceTableTransaction
in interface Catalog
ident
- 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)
Catalog
newReplaceTableTransaction
in interface Catalog
ident
- 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)
Catalog
newReplaceTableTransaction
in interface Catalog
ident
- 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)
Catalog
newReplaceTableTransaction
in interface Catalog
ident
- a table identifierschema
- a schemaorCreate
- whether to create the table if not existsTransaction
to replace the tablepublic boolean dropTable(TableIdentifier ident)
Catalog
public boolean dropTable(TableIdentifier ident, boolean purge)
Catalog
If purge is set to true the implementation should delete all data and metadata files.
public void renameTable(TableIdentifier from, TableIdentifier to)
Catalog
renameTable
in interface Catalog
from
- identifier of the table to renameto
- new table namepublic Table registerTable(TableIdentifier ident, java.lang.String metadataFileLocation)
Catalog
registerTable
in interface Catalog
ident
- a table identifiermetadataFileLocation
- the location of a metadata filepublic void createNamespace(Namespace ns, java.util.Map<java.lang.String,java.lang.String> props)
SupportsNamespaces
createNamespace
in interface SupportsNamespaces
ns
- a multi-part namespaceprops
- a string Map of properties for the given namespacepublic java.util.List<Namespace> listNamespaces(Namespace ns) throws NoSuchNamespaceException
SupportsNamespaces
For example, if table a.b.t exists, use 'SELECT NAMESPACE IN a' this method must return
Namepace.of("a","b") Namespace
.
listNamespaces
in interface SupportsNamespaces
Namespace
namesNoSuchNamespaceException
- If the namespace does not exist (optional)public java.util.Map<java.lang.String,java.lang.String> loadNamespaceMetadata(Namespace ns) throws NoSuchNamespaceException
SupportsNamespaces
loadNamespaceMetadata
in interface SupportsNamespaces
ns
- a namespace. Namespace
NoSuchNamespaceException
- If the namespace does not exist (optional)public boolean dropNamespace(Namespace ns) throws NamespaceNotEmptyException
SupportsNamespaces
dropNamespace
in interface SupportsNamespaces
ns
- a namespace. Namespace
NamespaceNotEmptyException
- If the namespace is not emptypublic boolean setProperties(Namespace ns, java.util.Map<java.lang.String,java.lang.String> props) throws NoSuchNamespaceException
SupportsNamespaces
Properties that are not in the given map are not modified or removed by this method.
setProperties
in interface SupportsNamespaces
ns
- a namespace. Namespace
props
- 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
SupportsNamespaces
Properties that are not in the given set are not modified or removed by this method.
removeProperties
in interface SupportsNamespaces
ns
- a namespace. Namespace
props
- a collection of metadata to apply to the namespaceNoSuchNamespaceException
- If the namespace does not exist (optional)public void setConf(java.lang.Object conf)
setConf
in interface Configurable<java.lang.Object>
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException