Class RESTSessionCatalog
- All Implemented Interfaces:
Closeable,AutoCloseable,SessionCatalog,ViewSessionCatalog,Configurable<Object>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.iceberg.catalog.BaseViewSessionCatalog
BaseViewSessionCatalog.AsViewCatalogNested classes/interfaces inherited from class org.apache.iceberg.catalog.BaseSessionCatalog
BaseSessionCatalog.AsCatalogNested classes/interfaces inherited from interface org.apache.iceberg.catalog.SessionCatalog
SessionCatalog.SessionContext -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRESTSessionCatalog(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.buildView(SessionCatalog.SessionContext context, TableIdentifier identifier) Instantiate a builder to create or replace a SQL view.voidclose()voidcommitTransaction(SessionCatalog.SessionContext context, List<TableCommit> commits) voidcreateNamespace(SessionCatalog.SessionContext context, Namespace namespace, Map<String, String> metadata) Create a namespace in the catalog.protected org.apache.iceberg.rest.RESTTableCachecreateTableCache(Map<String, String> props) booleandropNamespace(SessionCatalog.SessionContext context, Namespace ns) Drop a namespace.booleandropTable(SessionCatalog.SessionContext context, TableIdentifier identifier) Drop a table, without requesting that files are immediately deleted.booleandropView(SessionCatalog.SessionContext context, TableIdentifier identifier) Drop a view.voidinitialize(String name, Map<String, String> unresolved) Initialize given a custom name and a map of catalog properties.voidinvalidateTable(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.booleannamespaceExists(SessionCatalog.SessionContext context, Namespace namespace) Checks whether the Namespace exists.protected org.apache.iceberg.rest.RESTTableOperationsnewTableOps(RESTClient restClient, String path, Supplier<Map<String, String>> readHeaders, Supplier<Map<String, String>> mutationHeaderSupplier, FileIO fileIO, org.apache.iceberg.rest.RESTTableOperations.UpdateType updateType, List<MetadataUpdate> createChanges, TableMetadata current, Set<Endpoint> supportedEndpoints) Create a newRESTTableOperationsinstance for transaction-based operations (create or replace).protected org.apache.iceberg.rest.RESTTableOperationsnewTableOps(RESTClient restClient, String path, Supplier<Map<String, String>> readHeaders, Supplier<Map<String, String>> mutationHeaderSupplier, FileIO fileIO, TableMetadata current, Set<Endpoint> supportedEndpoints) Create a newRESTTableOperationsinstance for simple table operations.protected org.apache.iceberg.rest.RESTViewOperationsnewViewOps(RESTClient restClient, String path, Supplier<Map<String, String>> readHeaders, Supplier<Map<String, String>> mutationHeaderSupplier, ViewMetadata current, Set<Endpoint> supportedEndpoints) Create a newRESTViewOperationsinstance.booleanpurgeTable(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.registerTable(SessionCatalog.SessionContext context, TableIdentifier ident, String metadataFileLocation, boolean overwrite) Register a table.registerView(SessionCatalog.SessionContext context, TableIdentifier ident, String metadataFileLocation) Register a view if it does not exist.voidrenameTable(SessionCatalog.SessionContext context, TableIdentifier from, TableIdentifier to) Rename a table.voidrenameView(SessionCatalog.SessionContext context, TableIdentifier from, TableIdentifier to) Rename a view.voidbooleantableExists(SessionCatalog.SessionContext context, TableIdentifier identifier) Check whether table exists.booleanupdateNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns, Map<String, String> updates, Set<String> removals) Set a collection of properties on a namespace in the catalog.booleanviewExists(SessionCatalog.SessionContext context, TableIdentifier identifier) Check whether view exists.Methods inherited from class org.apache.iceberg.catalog.BaseViewSessionCatalog
asViewCatalogMethods inherited from class org.apache.iceberg.catalog.BaseSessionCatalog
asCatalog, name, properties, withContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.iceberg.catalog.SessionCatalog
createNamespace, listNamespacesMethods inherited from interface org.apache.iceberg.catalog.ViewSessionCatalog
invalidateView, name
-
Field Details
-
REST_PAGE_SIZE
Deprecated.will be removed in 1.12.0. UseRESTCatalogProperties.PAGE_SIZEinstead.- 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:SessionCatalogInitialize given a custom name and a map of catalog properties.- Specified by:
initializein interfaceSessionCatalog- Specified by:
initializein interfaceViewSessionCatalog- Overrides:
initializein classBaseSessionCatalog- Parameters:
name- a custom name for the catalogunresolved- catalog properties
-
createTableCache
-
setConf
- Specified by:
setConfin interfaceConfigurable<Object>
-
listTables
Description copied from interface:SessionCatalogReturn all the identifiers under this namespace.- Specified by:
listTablesin interfaceSessionCatalog- Parameters:
context- session contextns- a namespace- Returns:
- a list of identifiers for tables
-
dropTable
Description copied from interface:SessionCatalogDrop a table, without requesting that files are immediately deleted.Data and metadata files should be deleted according to the catalog's policy.
- Specified by:
dropTablein 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:SessionCatalogDrop a table and request that files are immediately deleted.- Specified by:
purgeTablein 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:SessionCatalogRename a table.- Specified by:
renameTablein interfaceSessionCatalog- Parameters:
context- session contextfrom- identifier of the table to renameto- new table name
-
tableExists
Description copied from interface:SessionCatalogCheck whether table exists.- Specified by:
tableExistsin interfaceSessionCatalog- Parameters:
context- session contextidentifier- a table identifier- Returns:
- true if the table exists, false otherwise
-
loadTable
Description copied from interface:SessionCatalogLoad a table.- Specified by:
loadTablein interfaceSessionCatalog- Parameters:
context- session contextidentifier- a table identifier- Returns:
- instance of
Tableimplementation referred bytableIdentifier
-
buildTable
public Catalog.TableBuilder buildTable(SessionCatalog.SessionContext context, TableIdentifier identifier, Schema schema) Description copied from interface:SessionCatalogCreate a builder to create a table or start a create/replace transaction.- Specified by:
buildTablein 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:SessionCatalogInvalidate 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:
invalidateTablein interfaceSessionCatalog- Parameters:
context- session contextident- a table identifier
-
registerTable
public Table registerTable(SessionCatalog.SessionContext context, TableIdentifier ident, String metadataFileLocation) Description copied from interface:SessionCatalogRegister a table if it does not exist.For overwrite support, see
SessionCatalog.registerTable(SessionContext, TableIdentifier, String, boolean).- Specified by:
registerTablein interfaceSessionCatalog- Parameters:
context- session contextident- a table identifiermetadataFileLocation- the location of a metadata file- Returns:
- a Table instance
-
registerTable
public Table registerTable(SessionCatalog.SessionContext context, TableIdentifier ident, String metadataFileLocation, boolean overwrite) Description copied from interface:SessionCatalogRegister a table.- Specified by:
registerTablein interfaceSessionCatalog- Parameters:
context- session contextident- a table identifiermetadataFileLocation- the location of a metadata fileoverwrite- whether to overwrite an existing table registration- Returns:
- a Table instance
-
createNamespace
public void createNamespace(SessionCatalog.SessionContext context, Namespace namespace, Map<String, String> metadata) Description copied from interface:SessionCatalogCreate a namespace in the catalog.- Specified by:
createNamespacein interfaceSessionCatalog- Parameters:
context- session contextnamespace- anamespacemetadata- a string Map of properties for the given namespace
-
listNamespaces
Description copied from interface:SessionCatalogList 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:
listNamespacesin interfaceSessionCatalog- Parameters:
context- session contextnamespace- anamespace- Returns:
- a List of child
Namespacenames from the given namespace
- Given:
-
namespaceExists
Description copied from interface:SessionCatalogChecks whether the Namespace exists.- Specified by:
namespaceExistsin interfaceSessionCatalog- Parameters:
context- session contextnamespace- anamespace- Returns:
- true if the Namespace exists, false otherwise
-
loadNamespaceMetadata
public Map<String,String> loadNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns) Description copied from interface:SessionCatalogLoad metadata properties for a namespace.- Specified by:
loadNamespaceMetadatain interfaceSessionCatalog- Parameters:
context- session contextns- anamespace- Returns:
- a string map of properties for the given namespace
-
dropNamespace
Description copied from interface:SessionCatalogDrop a namespace. If the namespace exists and was dropped, this will return true.- Specified by:
dropNamespacein 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:SessionCatalogSet 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:
updateNamespaceMetadatain interfaceSessionCatalog- Parameters:
context- session contextns- anamespaceupdates- properties to set for the namespaceremovals- properties to remove from the namespace
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
newTableOps
protected org.apache.iceberg.rest.RESTTableOperations newTableOps(RESTClient restClient, String path, Supplier<Map<String, String>> readHeaders, Supplier<Map<String, String>> mutationHeaderSupplier, FileIO fileIO, TableMetadata current, Set<Endpoint> supportedEndpoints) Create a newRESTTableOperationsinstance for simple table operations.This method can be overridden in subclasses to provide custom table operations implementations.
- Parameters:
restClient- the REST client to use for communicating with the catalog serverpath- the REST path for the tablereadHeaders- a supplier for additional HTTP headers to include in read requests (GET/HEAD)mutationHeaderSupplier- a supplier for additional HTTP headers to include in mutation requests (POST/DELETE)fileIO- the FileIO implementation for reading and writing table metadata and data filescurrent- the current table metadatasupportedEndpoints- the set of supported REST endpoints- Returns:
- a new RESTTableOperations instance
-
newTableOps
protected org.apache.iceberg.rest.RESTTableOperations newTableOps(RESTClient restClient, String path, Supplier<Map<String, String>> readHeaders, Supplier<Map<String, String>> mutationHeaderSupplier, FileIO fileIO, org.apache.iceberg.rest.RESTTableOperations.UpdateType updateType, List<MetadataUpdate> createChanges, TableMetadata current, Set<Endpoint> supportedEndpoints) Create a newRESTTableOperationsinstance for transaction-based operations (create or replace).This method can be overridden in subclasses to provide custom table operations implementations for transaction-based operations.
- Parameters:
restClient- the REST client to use for communicating with the catalog serverpath- the REST path for the tablereadHeaders- a supplier for additional HTTP headers to include in read requests (GET/HEAD)mutationHeaderSupplier- a supplier for additional HTTP headers to include in mutation requests (POST/DELETE)fileIO- the FileIO implementation for reading and writing table metadata and data filesupdateType- theRESTTableOperations.UpdateTypebeing performedcreateChanges- the list of metadata updates to apply during table creation or replacementcurrent- the current table metadata (may be null for CREATE operations)supportedEndpoints- the set of supported REST endpoints- Returns:
- a new RESTTableOperations instance
-
newViewOps
protected org.apache.iceberg.rest.RESTViewOperations newViewOps(RESTClient restClient, String path, Supplier<Map<String, String>> readHeaders, Supplier<Map<String, String>> mutationHeaderSupplier, ViewMetadata current, Set<Endpoint> supportedEndpoints) Create a newRESTViewOperationsinstance.This method can be overridden in subclasses to provide custom view operations implementations.
- Parameters:
restClient- the REST client to use for communicating with the catalog serverpath- the REST path for the viewreadHeaders- a supplier for additional HTTP headers to include in read requests (GET/HEAD)mutationHeaderSupplier- a supplier for additional HTTP headers to include in mutation requests (POST/DELETE)current- the current view metadatasupportedEndpoints- the set of supported REST endpoints- Returns:
- a new RESTViewOperations instance
-
commitTransaction
-
listViews
Description copied from interface:ViewSessionCatalogReturn all the identifiers under this namespace.- Specified by:
listViewsin interfaceViewSessionCatalog- Parameters:
namespace- a namespace- Returns:
- a list of identifiers for views
-
viewExists
Description copied from interface:ViewSessionCatalogCheck whether view exists.- Specified by:
viewExistsin interfaceViewSessionCatalog- Parameters:
identifier- a view identifier- Returns:
- true if the view exists, false otherwise
-
loadView
Description copied from interface:ViewSessionCatalogLoad a view.- Specified by:
loadViewin interfaceViewSessionCatalog- Parameters:
identifier- a view identifier- Returns:
- instance of
Viewimplementation referred by the identifier
-
buildView
Description copied from interface:ViewSessionCatalogInstantiate a builder to create or replace a SQL view.- Specified by:
buildViewin interfaceViewSessionCatalog- Parameters:
identifier- a view identifier- Returns:
- a view builder
-
dropView
Description copied from interface:ViewSessionCatalogDrop a view.- Specified by:
dropViewin interfaceViewSessionCatalog- Parameters:
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:ViewSessionCatalogRename a view.- Specified by:
renameViewin interfaceViewSessionCatalog- Parameters:
from- identifier of the view to renameto- new view identifier
-
registerView
public View registerView(SessionCatalog.SessionContext context, TableIdentifier ident, String metadataFileLocation) Description copied from interface:ViewSessionCatalogRegister a view if it does not exist.- Specified by:
registerViewin interfaceViewSessionCatalog- Parameters:
context- session contextident- a view identifiermetadataFileLocation- the location of a metadata file- Returns:
- a View instance
-