Package org.apache.iceberg.rest
Class RESTSessionCatalog
- java.lang.Object
-
- org.apache.iceberg.catalog.BaseSessionCatalog
-
- org.apache.iceberg.catalog.BaseViewSessionCatalog
-
- org.apache.iceberg.rest.RESTSessionCatalog
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,SessionCatalog
,ViewSessionCatalog
,Configurable<java.lang.Object>
public class RESTSessionCatalog extends BaseViewSessionCatalog implements Configurable<java.lang.Object>, java.io.Closeable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.iceberg.catalog.BaseViewSessionCatalog
BaseViewSessionCatalog.AsViewCatalog
-
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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
REST_PAGE_SIZE
-
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 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.org.apache.iceberg.rest.RESTSessionCatalog.RESTViewBuilder
buildView(SessionCatalog.SessionContext context, TableIdentifier identifier)
Instantiate a builder to create or replace a SQL view.void
close()
void
commitTransaction(SessionCatalog.SessionContext context, java.util.List<TableCommit> commits)
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.boolean
dropView(SessionCatalog.SessionContext context, TableIdentifier identifier)
Drop a view.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 child namespaces from the namespace.java.util.List<TableIdentifier>
listTables(SessionCatalog.SessionContext context, Namespace ns)
Return all the identifiers under this namespace.java.util.List<TableIdentifier>
listViews(SessionCatalog.SessionContext context, Namespace namespace)
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.View
loadView(SessionCatalog.SessionContext context, TableIdentifier identifier)
Load a view.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
renameView(SessionCatalog.SessionContext context, TableIdentifier from, TableIdentifier to)
Rename a view.void
setConf(java.lang.Object newConf)
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.BaseViewSessionCatalog
asViewCatalog
-
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
-
Methods inherited from interface org.apache.iceberg.catalog.ViewSessionCatalog
invalidateView, name, viewExists
-
-
-
-
Field Detail
-
REST_PAGE_SIZE
public static final java.lang.String REST_PAGE_SIZE
- See Also:
- Constant Field Values
-
-
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
- Specified by:
initialize
in interfaceViewSessionCatalog
- 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>
-
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 child namespaces from the namespace.For two existing tables named 'a.b.c.table' and 'a.b.d.table', this method returns:
- Given:
Namespace.empty()
- Returns:
Namespace.of("a")
- Given:
Namespace.of("a")
- Returns:
Namespace.of("a", "b")
- Given:
Namespace.of("a", "b")
- Returns:
Namespace.of("a", "b", "c")
andNamespace.of("a", "b", "d")
- Given:
Namespace.of("a", "b", "c")
- Returns: empty list, because there are no child namespaces
- Specified by:
listNamespaces
in interfaceSessionCatalog
- Parameters:
context
- session contextnamespace
- anamespace
- Returns:
- a List of child
Namespace
names from the given namespace
- Given:
-
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
-
commitTransaction
public void commitTransaction(SessionCatalog.SessionContext context, java.util.List<TableCommit> commits)
-
listViews
public java.util.List<TableIdentifier> listViews(SessionCatalog.SessionContext context, Namespace namespace)
Description copied from interface:ViewSessionCatalog
Return all the identifiers under this namespace.- Specified by:
listViews
in interfaceViewSessionCatalog
namespace
- a namespace- Returns:
- a list of identifiers for views
-
loadView
public View loadView(SessionCatalog.SessionContext context, TableIdentifier identifier)
Description copied from interface:ViewSessionCatalog
Load a view.- Specified by:
loadView
in interfaceViewSessionCatalog
identifier
- a view identifier- Returns:
- instance of
View
implementation referred by the identifier
-
buildView
public org.apache.iceberg.rest.RESTSessionCatalog.RESTViewBuilder buildView(SessionCatalog.SessionContext context, TableIdentifier identifier)
Description copied from interface:ViewSessionCatalog
Instantiate a builder to create or replace a SQL view.- Specified by:
buildView
in interfaceViewSessionCatalog
identifier
- a view identifier- Returns:
- a view builder
-
dropView
public boolean dropView(SessionCatalog.SessionContext context, TableIdentifier identifier)
Description copied from interface:ViewSessionCatalog
Drop a view.- Specified by:
dropView
in interfaceViewSessionCatalog
identifier
- a view identifier- Returns:
- true if the view was dropped, false if the view did not exist
-
renameView
public void renameView(SessionCatalog.SessionContext context, TableIdentifier from, TableIdentifier to)
Description copied from interface:ViewSessionCatalog
Rename a view.- Specified by:
renameView
in interfaceViewSessionCatalog
from
- identifier of the view to renameto
- new view identifier
-
-