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:
Closeable
,AutoCloseable
,SessionCatalog
,ViewSessionCatalog
,Configurable<Object>
public class RESTSessionCatalog
extends BaseViewSessionCatalog
implements Configurable<Object>, 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
-
Constructor Summary
ConstructorDescriptionRESTSessionCatalog
(Function<Map<String, String>, RESTClient> clientBuilder, BiFunction<SessionCatalog.SessionContext, Map<String, String>, FileIO> ioBuilder) -
Method Summary
Modifier and TypeMethodDescriptionbuildTable
(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, List<TableCommit> commits) void
createNamespace
(SessionCatalog.SessionContext context, Namespace namespace, Map<String, 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
(String name, Map<String, 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.listNamespaces
(SessionCatalog.SessionContext context, Namespace namespace) List child namespaces from the namespace.listTables
(SessionCatalog.SessionContext context, Namespace ns) Return all the identifiers under this namespace.listViews
(SessionCatalog.SessionContext context, Namespace namespace) Return all the identifiers under this namespace.loadNamespaceMetadata
(SessionCatalog.SessionContext context, Namespace ns) Load metadata properties for a namespace.loadTable
(SessionCatalog.SessionContext context, TableIdentifier identifier) Load a table.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.registerTable
(SessionCatalog.SessionContext context, TableIdentifier ident, 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
boolean
updateNamespaceMetadata
(SessionCatalog.SessionContext context, Namespace ns, Map<String, String> updates, Set<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 Details
-
REST_PAGE_SIZE
- See Also:
-
-
Constructor Details
-
RESTSessionCatalog
public RESTSessionCatalog() -
RESTSessionCatalog
public RESTSessionCatalog(Function<Map<String, String>, RESTClient> clientBuilder, BiFunction<SessionCatalog.SessionContext, Map<String, String>, FileIO> ioBuilder)
-
-
Method Details
-
initialize
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
- Specified by:
setConf
in interfaceConfigurable<Object>
-
listTables
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
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
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
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
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, 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, Map<String, 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
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 Map<String,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
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, Map<String, String> updates, Set<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
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
commitTransaction
-
listViews
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
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
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
-