Package org.apache.iceberg.hadoop
Class HadoopCatalog
- java.lang.Object
-
- org.apache.iceberg.BaseMetastoreCatalog
-
- org.apache.iceberg.hadoop.HadoopCatalog
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,org.apache.hadoop.conf.Configurable,Catalog,SupportsNamespaces
public class HadoopCatalog extends BaseMetastoreCatalog implements java.io.Closeable, SupportsNamespaces, org.apache.hadoop.conf.Configurable
HadoopCatalog provides a way to use table names like db.table to work with path-based tables under a common location. It uses a specified directory under a specified filesystem as the warehouse directory, and organizes multiple levels directories that mapped to the database, namespace and the table respectively. The HadoopCatalog takes a location as the warehouse directory. When creating a table such as $db.$tbl, it creates $db/$tbl directory under the warehouse directory, and put the table metadata into that directory. The HadoopCatalog now supportsCatalog.createTable(org.apache.iceberg.catalog.TableIdentifier, org.apache.iceberg.Schema, org.apache.iceberg.PartitionSpec, java.lang.String, java.util.Map<java.lang.String, java.lang.String>),Catalog.dropTable(org.apache.iceberg.catalog.TableIdentifier), theCatalog.renameTable(org.apache.iceberg.catalog.TableIdentifier, org.apache.iceberg.catalog.TableIdentifier)is not supported yet. Note: The HadoopCatalog requires that the underlying file system supports atomic rename.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.iceberg.BaseMetastoreCatalog
BaseMetastoreCatalog.BaseMetastoreCatalogTableBuilder
-
Nested classes/interfaces inherited from interface org.apache.iceberg.catalog.Catalog
Catalog.TableBuilder
-
-
Constructor Summary
Constructors Constructor Description HadoopCatalog()HadoopCatalog(org.apache.hadoop.conf.Configuration conf)Deprecated.please use the no-arg constructor, setConf and initialize to construct the catalog.HadoopCatalog(org.apache.hadoop.conf.Configuration conf, java.lang.String warehouseLocation)Deprecated.please use the no-arg constructor, setConf and initialize to construct the catalog.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Catalog.TableBuilderbuildTable(TableIdentifier identifier, Schema schema)Instantiate a builder to either create a table or start a create/replace transaction.voidclose()voidcreateNamespace(Namespace namespace, java.util.Map<java.lang.String,java.lang.String> meta)Create a namespace in the catalog.protected java.lang.StringdefaultWarehouseLocation(TableIdentifier tableIdentifier)booleandropNamespace(Namespace namespace)Drop a namespace.booleandropTable(TableIdentifier identifier, boolean purge)Drop a table; optionally delete data and metadata files.org.apache.hadoop.conf.ConfigurationgetConf()voidinitialize(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> properties)Initialize a catalog given a custom name and a map of catalog properties.protected booleanisValidIdentifier(TableIdentifier identifier)java.util.List<Namespace>listNamespaces(Namespace namespace)List namespaces from the namespace.java.util.List<TableIdentifier>listTables(Namespace namespace)Return all the identifiers under this namespace.java.util.Map<java.lang.String,java.lang.String>loadNamespaceMetadata(Namespace namespace)Load metadata properties for a namespace.java.lang.Stringname()Return the name for this catalog.protected TableOperationsnewTableOps(TableIdentifier identifier)booleanremoveProperties(Namespace namespace, java.util.Set<java.lang.String> properties)Remove a set of metadata from a namespace in the catalog.voidrenameTable(TableIdentifier from, TableIdentifier to)Rename a table.voidsetConf(org.apache.hadoop.conf.Configuration conf)booleansetProperties(Namespace namespace, java.util.Map<java.lang.String,java.lang.String> properties)Apply a set of metadata to a namespace in the catalog.java.lang.StringtoString()-
Methods inherited from class org.apache.iceberg.BaseMetastoreCatalog
createTable, fullTableName, loadTable, newCreateTableTransaction, newReplaceTableTransaction
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.iceberg.catalog.Catalog
createTable, createTable, createTable, dropTable, newCreateTableTransaction, newCreateTableTransaction, newCreateTableTransaction, newReplaceTableTransaction, newReplaceTableTransaction, newReplaceTableTransaction, tableExists
-
Methods inherited from interface org.apache.iceberg.catalog.SupportsNamespaces
createNamespace, listNamespaces, namespaceExists
-
-
-
-
Constructor Detail
-
HadoopCatalog
public HadoopCatalog()
-
HadoopCatalog
@Deprecated public HadoopCatalog(org.apache.hadoop.conf.Configuration conf, java.lang.String warehouseLocation)Deprecated.please use the no-arg constructor, setConf and initialize to construct the catalog. Will be removed in v0.13.0The constructor of the HadoopCatalog. It uses the passed location as its warehouse directory.- Parameters:
conf- The Hadoop configurationwarehouseLocation- The location used as warehouse directory
-
HadoopCatalog
@Deprecated public HadoopCatalog(org.apache.hadoop.conf.Configuration conf)
Deprecated.please use the no-arg constructor, setConf and initialize to construct the catalog. Will be removed in v0.13.0The constructor of the HadoopCatalog. It gets the value offs.defaultFSproperty from the passed Hadoop configuration as its default file system, and use the default directoryiceberg/warehouseas the warehouse directory.- Parameters:
conf- The Hadoop configuration
-
-
Method Detail
-
initialize
public void initialize(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> properties)Description copied from interface:CatalogInitialize a catalog given a custom name and a map of catalog properties.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.
- Specified by:
initializein interfaceCatalog- Parameters:
name- a custom name for the catalogproperties- catalog properties
-
name
public java.lang.String name()
Description copied from interface:CatalogReturn the name for this catalog.
-
listTables
public java.util.List<TableIdentifier> listTables(Namespace namespace)
Description copied from interface:CatalogReturn all the identifiers under this namespace.- Specified by:
listTablesin interfaceCatalog- Parameters:
namespace- a namespace- Returns:
- a list of identifiers for tables
-
isValidIdentifier
protected boolean isValidIdentifier(TableIdentifier identifier)
- Overrides:
isValidIdentifierin classBaseMetastoreCatalog
-
newTableOps
protected TableOperations newTableOps(TableIdentifier identifier)
- Specified by:
newTableOpsin classBaseMetastoreCatalog
-
defaultWarehouseLocation
protected java.lang.String defaultWarehouseLocation(TableIdentifier tableIdentifier)
- Specified by:
defaultWarehouseLocationin classBaseMetastoreCatalog
-
dropTable
public boolean dropTable(TableIdentifier identifier, boolean purge)
Description copied from interface:CatalogDrop a table; optionally delete data and metadata files.If purge is set to true the implementation should delete all data and metadata files.
-
renameTable
public void renameTable(TableIdentifier from, TableIdentifier to)
Description copied from interface:CatalogRename a table.- Specified by:
renameTablein interfaceCatalog- Parameters:
from- identifier of the table to renameto- new table name
-
createNamespace
public void createNamespace(Namespace namespace, java.util.Map<java.lang.String,java.lang.String> meta)
Description copied from interface:SupportsNamespacesCreate a namespace in the catalog.- Specified by:
createNamespacein interfaceSupportsNamespaces- Parameters:
namespace- a multi-part namespacemeta- a string Map of properties for the given namespace
-
listNamespaces
public java.util.List<Namespace> listNamespaces(Namespace namespace)
Description copied from interface:SupportsNamespacesList 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:
listNamespacesin interfaceSupportsNamespaces- Returns:
- a List of namespace
Namespacenames
-
dropNamespace
public boolean dropNamespace(Namespace namespace)
Description copied from interface:SupportsNamespacesDrop a namespace. If the namespace exists and was dropped, this will return true.- Specified by:
dropNamespacein interfaceSupportsNamespaces- Parameters:
namespace- a namespace.Namespace- Returns:
- true if the namespace was dropped, false otherwise.
-
setProperties
public boolean setProperties(Namespace namespace, java.util.Map<java.lang.String,java.lang.String> properties)
Description copied from interface:SupportsNamespacesApply a set of metadata to a namespace in the catalog.- Specified by:
setPropertiesin interfaceSupportsNamespaces- Parameters:
namespace- a namespace.Namespaceproperties- a collection of metadata to apply to the namespace
-
removeProperties
public boolean removeProperties(Namespace namespace, java.util.Set<java.lang.String> properties)
Description copied from interface:SupportsNamespacesRemove a set of metadata from a namespace in the catalog.- Specified by:
removePropertiesin interfaceSupportsNamespaces- Parameters:
namespace- a namespace.Namespaceproperties- a collection of metadata to apply to the namespace
-
loadNamespaceMetadata
public java.util.Map<java.lang.String,java.lang.String> loadNamespaceMetadata(Namespace namespace)
Description copied from interface:SupportsNamespacesLoad metadata properties for a namespace.- Specified by:
loadNamespaceMetadatain interfaceSupportsNamespaces- Parameters:
namespace- a namespace.Namespace- Returns:
- a string map of properties for the given namespace
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classBaseMetastoreCatalog
-
buildTable
public Catalog.TableBuilder buildTable(TableIdentifier identifier, Schema schema)
Description copied from interface:CatalogInstantiate a builder to either create a table or start a create/replace transaction.- Specified by:
buildTablein interfaceCatalog- Overrides:
buildTablein classBaseMetastoreCatalog- Parameters:
identifier- a table identifierschema- a schema- Returns:
- the builder to create a table or start a create/replace transaction
-
setConf
public void setConf(org.apache.hadoop.conf.Configuration conf)
- Specified by:
setConfin interfaceorg.apache.hadoop.conf.Configurable
-
getConf
public org.apache.hadoop.conf.Configuration getConf()
- Specified by:
getConfin interfaceorg.apache.hadoop.conf.Configurable
-
-