Package org.apache.iceberg.rest
Class RESTSessionCatalog
- java.lang.Object
-
- org.apache.iceberg.catalog.BaseSessionCatalog
-
- org.apache.iceberg.rest.RESTSessionCatalog
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,SessionCatalog
,Configurable<java.lang.Object>
public class RESTSessionCatalog extends BaseSessionCatalog implements Configurable<java.lang.Object>, java.io.Closeable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.iceberg.catalog.BaseSessionCatalog
BaseSessionCatalog.AsCatalog
-
Nested classes/interfaces inherited from interface org.apache.iceberg.catalog.SessionCatalog
SessionCatalog.SessionContext
-
-
Constructor Summary
Constructors Constructor Description RESTSessionCatalog()
RESTSessionCatalog(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,RESTClient> clientBuilder, java.util.function.BiFunction<SessionCatalog.SessionContext,java.util.Map<java.lang.String,java.lang.String>,FileIO> ioBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Catalog.TableBuilder
buildTable(SessionCatalog.SessionContext context, TableIdentifier identifier, Schema schema)
Create a builder to create a table or start a create/replace transaction.void
close()
void
createNamespace(SessionCatalog.SessionContext context, Namespace namespace, java.util.Map<java.lang.String,java.lang.String> metadata)
Create a namespace in the catalog.boolean
dropNamespace(SessionCatalog.SessionContext context, Namespace ns)
Drop a namespace.boolean
dropTable(SessionCatalog.SessionContext context, TableIdentifier identifier)
Drop a table, without requesting that files are immediately deleted.void
initialize(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> unresolved)
Initialize given a custom name and a map of catalog properties.void
invalidateTable(SessionCatalog.SessionContext context, TableIdentifier ident)
Invalidate cached table metadata from current catalog.java.util.List<Namespace>
listNamespaces(SessionCatalog.SessionContext context, Namespace namespace)
List namespaces from the namespace.java.util.List<TableIdentifier>
listTables(SessionCatalog.SessionContext context, Namespace ns)
Return all the identifiers under this namespace.java.util.Map<java.lang.String,java.lang.String>
loadNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns)
Load metadata properties for a namespace.Table
loadTable(SessionCatalog.SessionContext context, TableIdentifier identifier)
Load a table.boolean
purgeTable(SessionCatalog.SessionContext context, TableIdentifier identifier)
Drop a table and request that files are immediately deleted.Table
registerTable(SessionCatalog.SessionContext context, TableIdentifier ident, java.lang.String metadataFileLocation)
Register a table if it does not exist.void
renameTable(SessionCatalog.SessionContext context, TableIdentifier from, TableIdentifier to)
Rename a table.void
setConf(java.lang.Object newConf)
void
setConf(org.apache.hadoop.conf.Configuration newConf)
Deprecated.will be removed in 1.3.0; usesetConf(Object)
boolean
updateNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns, java.util.Map<java.lang.String,java.lang.String> updates, java.util.Set<java.lang.String> removals)
Set a collection of properties on a namespace in the catalog.-
Methods inherited from class org.apache.iceberg.catalog.BaseSessionCatalog
asCatalog, name, properties, withContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.iceberg.catalog.SessionCatalog
createNamespace, listNamespaces, namespaceExists, tableExists
-
-
-
-
Constructor Detail
-
RESTSessionCatalog
public RESTSessionCatalog()
-
RESTSessionCatalog
public RESTSessionCatalog(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,RESTClient> clientBuilder, java.util.function.BiFunction<SessionCatalog.SessionContext,java.util.Map<java.lang.String,java.lang.String>,FileIO> ioBuilder)
-
-
Method Detail
-
initialize
public void initialize(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> unresolved)
Description copied from interface:SessionCatalog
Initialize given a custom name and a map of catalog properties.- Specified by:
initialize
in interfaceSessionCatalog
- Overrides:
initialize
in classBaseSessionCatalog
- Parameters:
name
- a custom name for the catalogunresolved
- catalog properties
-
setConf
public void setConf(java.lang.Object newConf)
- Specified by:
setConf
in interfaceConfigurable<java.lang.Object>
-
setConf
@Deprecated public void setConf(org.apache.hadoop.conf.Configuration newConf)
Deprecated.will be removed in 1.3.0; usesetConf(Object)
-
listTables
public java.util.List<TableIdentifier> listTables(SessionCatalog.SessionContext context, Namespace ns)
Description copied from interface:SessionCatalog
Return all the identifiers under this namespace.- Specified by:
listTables
in interfaceSessionCatalog
- Parameters:
context
- session contextns
- a namespace- Returns:
- a list of identifiers for tables
-
dropTable
public boolean dropTable(SessionCatalog.SessionContext context, TableIdentifier identifier)
Description copied from interface:SessionCatalog
Drop a table, without requesting that files are immediately deleted.Data and metadata files should be deleted according to the catalog's policy.
- Specified by:
dropTable
in interfaceSessionCatalog
- Parameters:
context
- session contextidentifier
- a table identifier- Returns:
- true if the table was dropped, false if the table did not exist
-
purgeTable
public boolean purgeTable(SessionCatalog.SessionContext context, TableIdentifier identifier)
Description copied from interface:SessionCatalog
Drop a table and request that files are immediately deleted.- Specified by:
purgeTable
in interfaceSessionCatalog
- Parameters:
context
- session contextidentifier
- a table identifier- Returns:
- true if the table was dropped and purged, false if the table did not exist
-
renameTable
public void renameTable(SessionCatalog.SessionContext context, TableIdentifier from, TableIdentifier to)
Description copied from interface:SessionCatalog
Rename a table.- Specified by:
renameTable
in interfaceSessionCatalog
- Parameters:
context
- session contextfrom
- identifier of the table to renameto
- new table name
-
loadTable
public Table loadTable(SessionCatalog.SessionContext context, TableIdentifier identifier)
Description copied from interface:SessionCatalog
Load a table.- Specified by:
loadTable
in interfaceSessionCatalog
- Parameters:
context
- session contextidentifier
- a table identifier- Returns:
- instance of
Table
implementation referred bytableIdentifier
-
buildTable
public Catalog.TableBuilder buildTable(SessionCatalog.SessionContext context, TableIdentifier identifier, Schema schema)
Description copied from interface:SessionCatalog
Create a builder to create a table or start a create/replace transaction.- Specified by:
buildTable
in interfaceSessionCatalog
- Parameters:
context
- session contextidentifier
- a table identifierschema
- a schema- Returns:
- the builder to create a table or start a create/replace transaction
-
invalidateTable
public void invalidateTable(SessionCatalog.SessionContext context, TableIdentifier ident)
Description copied from interface:SessionCatalog
Invalidate cached table metadata from current catalog.If the table is already loaded or cached, drop cached data. If the table does not exist or is not cached, do nothing.
- Specified by:
invalidateTable
in interfaceSessionCatalog
- Parameters:
context
- session contextident
- a table identifier
-
registerTable
public Table registerTable(SessionCatalog.SessionContext context, TableIdentifier ident, java.lang.String metadataFileLocation)
Description copied from interface:SessionCatalog
Register a table if it does not exist.- Specified by:
registerTable
in interfaceSessionCatalog
- Parameters:
context
- session contextident
- a table identifiermetadataFileLocation
- the location of a metadata file- Returns:
- a Table instance
-
createNamespace
public void createNamespace(SessionCatalog.SessionContext context, Namespace namespace, java.util.Map<java.lang.String,java.lang.String> metadata)
Description copied from interface:SessionCatalog
Create a namespace in the catalog.- Specified by:
createNamespace
in interfaceSessionCatalog
- Parameters:
context
- session contextnamespace
- anamespace
metadata
- a string Map of properties for the given namespace
-
listNamespaces
public java.util.List<Namespace> listNamespaces(SessionCatalog.SessionContext context, Namespace namespace)
Description copied from interface:SessionCatalog
List namespaces from the namespace.For example, if table a.b.t exists, use 'SELECT NAMESPACE IN a' this method must return Namepace.of("a","b")
Namespace
.- Specified by:
listNamespaces
in interfaceSessionCatalog
- Parameters:
context
- session contextnamespace
- anamespace
- Returns:
- a List of namespace
Namespace
names
-
loadNamespaceMetadata
public java.util.Map<java.lang.String,java.lang.String> loadNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns)
Description copied from interface:SessionCatalog
Load metadata properties for a namespace.- Specified by:
loadNamespaceMetadata
in interfaceSessionCatalog
- Parameters:
context
- session contextns
- anamespace
- Returns:
- a string map of properties for the given namespace
-
dropNamespace
public boolean dropNamespace(SessionCatalog.SessionContext context, Namespace ns)
Description copied from interface:SessionCatalog
Drop a namespace. If the namespace exists and was dropped, this will return true.- Specified by:
dropNamespace
in interfaceSessionCatalog
- Parameters:
context
- session contextns
- anamespace
- Returns:
- true if the namespace was dropped, false otherwise.
-
updateNamespaceMetadata
public boolean updateNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns, java.util.Map<java.lang.String,java.lang.String> updates, java.util.Set<java.lang.String> removals)
Description copied from interface:SessionCatalog
Set a collection of properties on a namespace in the catalog.Properties that are not in the given map are not modified or removed by this method.
- Specified by:
updateNamespaceMetadata
in interfaceSessionCatalog
- Parameters:
context
- session contextns
- anamespace
updates
- properties to set for the namespaceremovals
- properties to remove from the namespace
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-